文档章节

测试博客

54_键盘上的幽灵
 54_键盘上的幽灵
发布于 2017/05/18 14:00
字数 1200
阅读 5
收藏 0

测试代码高亮

java

public static String sayHello(String name){
	StringBuffer sb  = new StringBuffer();
    sb.append("hello,");
    sb.append(name);
	return sb.toString();
}

javascript

function sayHello(String name){
    var rs = "hello,";
    rs += name;
    return rs;
}

bash

#!/usr/bin/bash
cat /tmp/hello.txt
tail -f /tmp/hello.log

perl

#!/usr/bin/perl
@arrays = ("aaa", "bbb", "ccc");
print "$_\n" foreach @arrays;
system "ls /tmp";

sub sayHello(){
   my $name = shift @_;
   return "hello" . $name;
}

CentOS 6.8 安装

Linux 系统有很多, 主要分两种, 一种是RedHat 系列, 一种是Ubuntu 系列. 笔者选择的是RedHat 系列的Centos, 版本为6.8, 因为Centos 的yum 软件安装时免费的, 所以安装一些软件比较方便.<br/> 虚拟机软件主要有VMware(简称VM)和 VirtualBox (简称VB),VM 需要收费, 只适用于windows 系统, 没有linux 版本; VB 是免费的, 有对应的Linux 版本, 但是笔者习惯于VM . VM 默认鼠标脱离快捷键为: Ctrl + Alt

一 使用VM 新建虚拟机

1.1 点击新建虚拟机,选择典型,点击下一步

.......

1.2 点击浏览,选择Centos 镜像文件

.......

1.3 输入虚拟机名称,用户名和密码(并不知道这一步是干嘛)

.......

1.4 输入虚拟机名称, 点击浏览选择虚拟机安装位置, 点击下一步

.......

1.5 设置虚拟机硬盘大小, 默认为20G, 够用了, 点击下一步

.......

1.6 点击自定义硬件,可以设置cpu个数, 内存大小等参数. 此处默认, 点击完成,即创建完毕

.......

测试显示元符号

* # >


#收回root 账号, 新建管理员账号

笔者认为,安装完linux 系统之后, 应该第一时间创建管理员用户,尽量避免使用root用户进行操作,这主要是因为root 用户权限过大, 如果不小心执行了一个 rm -rf / 的操作, 那么整个系统就崩溃了. 尤其是在工作中, 大家技术参差不齐, 更应该把root账户收回,为每个人建立起独立的账户.

1. 新建管理员用户

1.1 创建管理员用户admin, 并添加到root 组

[root@localhost ~]# useradd admin

1.2 设置密码

[root@localhost ~]# passwd admin
Changing password for user admin.
New password:
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

1.3 将admin 添加到 root 组中

[root@localhost ~]# usermod -aG root admin

1.4 查看管理员账号

[root@localhost ~]# id admin
uid=500(admin) gid=500(admin) groups=500(admin),0(root)

2. 修改分区权限

[root@localhost ~]# chmod 775 /opt/ /usr/etc /usr/local/ /var/data /var/logs /var/run
[root@localhost ~]# ll -d /opt/ /usr/etc /usr/local/ /var/data /var/logs /var/run
drwxrwxr-x. 7 root root 4096 May 21 06:43 /opt/
drwxrwxr-x. 2 root root 4096 Sep 23 2011 /usr/etc
drwxrwxr-x. 13 root root 4096 May 21 04:50 /usr/local/
drwxrwxr-x. 5 root root 4096 May 21 07:20 /var/data
drwxrwxr-x. 4 root root 4096 May 21 07:24 /var/logs
drwxrwxr-x. 21 root root 4096 May 22 22:13 /var/run

3. 修改sudo 文件

[root@localhost ~]# visudo
\#\# Sudoers allows particular users to run various commands as
\#\# the root user, without needing the root password.
\#\#
\#\# Examples are provided at the bottom of the file for collections
\#\# of related commands, which can then be delegated out to particular
\#\# users or groups.
\#\#
\#\# This file must be edited with the 'visudo' command.

\#\# Host Aliases
\#\# Groups of machines. You may prefer to use hostnames (perhaps using
\#\# wildcards for entire domains) or IP addresses instead.
\# Host_Alias FILESERVERS = fs1, fs2
\# Host_Alias MAILSERVERS = smtp, smtp2

\#\# User Aliases
\#\# These aren't often necessary, as you can use regular groups
\#\# (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
\#\# rather than USERALIAS
\# User_Alias ADMINS = jsmith, mikem


\#\# Command Aliases
\#\# These are groups of related commands...

\#\# Networking
**Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool **

\#\# Installation and management of software
**Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum **

\#\# Services
**Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig **

\#\# Updating the locate database
**Cmnd_Alias LOCATE = /usr/bin/updatedb**

\#\# Storage
**Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount**

\#\# Delegating permissions
**Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp **

\#\# Processes
**Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall**

\#\# Drivers
**Cmnd_Alias DRIVERS = /sbin/modprobe**

\# Defaults specification

\#
\# Refuse to run if unable to disable echo on the tty.
\#
Defaults !visiblepw

\#
\# Preserving HOME has security implications since many programs
\# use it when searching for configuration files. Note that HOME
\# is already set when the the env_reset option is enabled, so
\# this option is only effective for configurations where either
\# env_reset is disabled or HOME is present in the env_keep list.
\#
Defaults always_set_home

Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

\#
\# Adding HOME to env_keep may enable a user to run unrestricted
\# commands via sudo.
\#
\# Defaults env_keep += "HOME"

Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin

\#\# Next comes the main part: which users can run what software on
\#\# which machines (the sudoers file can be shared between multiple
\#\# systems).
\#\# Syntax:
\#\#
\#\# user MACHINE=COMMANDS
\#\#
\#\# The COMMANDS section may have other options added to it.
\#\#
\#\# Allow root to run any commands anywhere
root ALL=(ALL) ALL

\#\# Allows members of the 'sys' group to run networking, software,
\#\# service management apps and more.
**admin ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS**

\#\# Allows people in group wheel to run all commands
\# %wheel ALL=(ALL) ALL

\#\# Same thing without a password
\# %wheel ALL=(ALL) NOPASSWD: ALL

\#\# Allows members of the users group to mount and unmount the
\#\# cdrom as root
%root ALL=/bin/mount, /bin/umount /mnt/cdrom

\#\# Allows members of the users group to shutdown this system
\# %users localhost=/sbin/shutdown -h now

\#\# Read drop-in files from /etc/sudoers.d (the \# here does not mean a comment)
\#includedir /etc/sudoers.d

© 著作权归作者所有

54_键盘上的幽灵
粉丝 0
博文 24
码字总数 23833
作品 0
西城
程序员
私信 提问

暂无文章

golang-字符串-地址分析

demo package mainimport "fmt"func main() {str := "map.baidu.com"fmt.Println(&str, str)str = str[0:5]fmt.Println(&str, str)str = "abc"fmt.Println(&s......

李琼涛
48分钟前
4
0
Spring Boot WebFlux 增删改查完整实战 demo

03:WebFlux Web CRUD 实践 前言 上一篇基于功能性端点去创建一个简单服务,实现了 Hello 。这一篇用 Spring Boot WebFlux 的注解控制层技术创建一个 CRUD WebFlux 应用,让开发更方便。这里...

泥瓦匠BYSocket
今天
6
0
从0开始学FreeRTOS-(列表与列表项)-3

FreeRTOS列表&列表项的源码解读 第一次看列表与列表项的时候,感觉很像是链表,虽然我自己的链表也不太会,但是就是感觉很像。 在FreeRTOS中,列表与列表项使用得非常多,是FreeRTOS的一个数...

杰杰1号
今天
4
0
Java反射

Java 反射 反射是框架设计的灵魂(使用的前提条件:必须先得到代表的字节码的 Class,Class 类 用于表示.class 文件(字节码)) 一、反射的概述 定义:JAVA 反射机制是在运行状态中,对于任...

zzz1122334
今天
5
0
聊聊nacos的LocalConfigInfoProcessor

序 本文主要研究一下nacos的LocalConfigInfoProcessor LocalConfigInfoProcessor nacos-1.1.3/client/src/main/java/com/alibaba/nacos/client/config/impl/LocalConfigInfoProcessor.java p......

go4it
昨天
8
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部