CentOS 6.8(32)相关操作
来源:互联网 发布:lacie setup 软件下载 编辑:程序博客网 时间:2024/05/29 16:28
CentOS6.8(32)
=======================
查看Linux内核版本命令 cat /proc/version
查看Linux系统版本的命令 lsb_release -a
查看linux机器是32位还是64位的方法:file /bin/ls
0. Linux 启动模式,text/graphics
如果想开机直接进入“命令行模式”,可编辑 /etc/inittab 文件,设置为 id:3:initdefault:
如果想直接进入“窗口模式”,则设置为 id:5:initdefault:
1. linux 用户管理
暂时修改:
hostname
hostnmae 主机名
永久修改:
1)通过配置文件/etc/sysconfig/network修改。
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
2)
更改/etc下的hosts文件,在提示符下输入vi /etc/hosts,
然后将localhost.localdomain改为想要设置的主机名。
"not in the sudoers file"
/etc/sudoers ,
找到 Allow root to ruan any commands anywhere这一行
在root ALL=(ALL) ALL 下面另起一行,输入“xx ALL=(ALL) ALL”(xx表示你的用户名),然后保存退出
groups
usermod -G adm,root liugf
useradd -d /home/hadoop -m hadoop
passwd username
2. Linux 网络管理
网络信息查看:
cat /etc/sysconfig/network-scripts/ifcfg-eth0
(1) 配置eth0的IP地址, 同时激活该设备
sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
(2) 添加默认网关
sudo route add default gw 192.168.1.1
(3) 配置DNS
$ sudo vi /etc/resolv.conf [5.0 时代]
#激活设备
ifconfig eth0 up
#禁用设备
ifconfig eth0 down
route -n 查看下路由表
临时修改方案,重启后失效:
#ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
永久修改方案:
1. 修改网络配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0
动态IP配置:
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:03:47:2C:D5:40
ONBOOT=yes
TYPE=Ethernet
静态IP配置:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.223
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=202.96.128.86
DOMAIN=202.96.128.166
HWADDR=00:03:47:2C:D5:40
ONBOOT=yes
TYPE=Ethernet
2. 重启服务生效:service network restart
在打开的终端页面,输入如下代码:
ssh user@hostname
注:上边代码为固定格式,其中
user 为 linux 服务器的管理员名称
hostname 为 linux 服务器的IP
利用ssh传输文件:
1、从服务器上下载文件
scp username@servername:/path/filename /var/www/local_dir(本地目录)
例如scp root@192.168.0.101:/var/www/test.txt
把192.168.0.101上的/var/www/test.txt 的文件下载到/var/www/local_dir(本地目录)
2、上传本地文件到服务器
scp /path/filename username@servername:/path
例如scp /var/www/test.php root@192.168.0.101:/var/www/
把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中
3、从服务器下载整个目录
scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录)
例如:scp -r root@192.168.0.101:/var/www/test /var/www/
4、上传目录到服务器
scp -r local_dir username@servername:remote_dir
例如:scp -r test root@192.168.0.101:/var/www/
把当前目录下的test目录上传到服务器的/var/www/ 目录
5.查看目录或文件:
ssh user@host command ls "/path/*.tgz"
3.Linux 源修改:
第一步:备份你的原镜像文件,以免出错后可以恢复。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum clean all
yum makecache
4.Linux 终端颜色
~/.bashrc
export LS_COLORS=$LS_COLORS:'di=1;33:' ;
Some nice color choices (in this case 0;35 it is purple) are:
Blue = 34
Green = 32
Light Green = 1;32
Cyan = 36
Red = 31
Purple = 35
Brown = 33
Yellow = 1;33
white = 1;37
Light Grey = 0;37
Black = 30
Dark Grey= 1;30
The first number is the style (1=bold),
followed by a semicolon, and then the actual number of the color,
possible styles are:
0 = default colour
1 = bold
4 = underlined
5 = flashing text
7 = reverse field
40 = black background
41 = red background
42 = green background
43 = orange background
44 = blue background
45 = purple background
46 = cyan background
47 = grey background
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background
All possible colors:
31 = red
32 = green
33 = orange
34 = blue
35 = purple
36 = cyan
37 = grey
90 = dark grey
91 = light red
92 = light green
93 = yellow
94 = light blue
95 = light purple
96 = turquoise
di=1;4;31;42
in your LS_COLORS variable would make directories appear
in bold underlined red text with a green background!
ou can also change other kinds of files when using the ls command by defining each kind with:
di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has 'x' set in permissions).
*.rpm = files with the ending .rpm
5. 禁用防火墙
centos 7:
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
之前的版本:
service iptables stop #停止
chkconfig iptables off #禁用
=======================
查看Linux内核版本命令 cat /proc/version
查看Linux系统版本的命令 lsb_release -a
查看linux机器是32位还是64位的方法:file /bin/ls
0. Linux 启动模式,text/graphics
如果想开机直接进入“命令行模式”,可编辑 /etc/inittab 文件,设置为 id:3:initdefault:
如果想直接进入“窗口模式”,则设置为 id:5:initdefault:
1. linux 用户管理
groupadd hadoop
useradd -g hadoop -G adm,root hadoop
passwd hadoop
暂时修改:
hostname
hostnmae 主机名
永久修改:
1)通过配置文件/etc/sysconfig/network修改。
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
2)
更改/etc下的hosts文件,在提示符下输入vi /etc/hosts,
然后将localhost.localdomain改为想要设置的主机名。
"not in the sudoers file"
/etc/sudoers ,
找到 Allow root to ruan any commands anywhere这一行
在root ALL=(ALL) ALL 下面另起一行,输入“xx ALL=(ALL) ALL”(xx表示你的用户名),然后保存退出
groups
usermod -G adm,root liugf
useradd -d /home/hadoop -m hadoop
passwd username
2. Linux 网络管理
网络信息查看:
cat /etc/sysconfig/network-scripts/ifcfg-eth0
(1) 配置eth0的IP地址, 同时激活该设备
sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
(2) 添加默认网关
sudo route add default gw 192.168.1.1
(3) 配置DNS
$ sudo vi /etc/resolv.conf [5.0 时代]
#激活设备
ifconfig eth0 up
#禁用设备
ifconfig eth0 down
route -n 查看下路由表
临时修改方案,重启后失效:
#ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
永久修改方案:
1. 修改网络配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0
动态IP配置:
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:03:47:2C:D5:40
ONBOOT=yes
TYPE=Ethernet
静态IP配置:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.223
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=202.96.128.86
DOMAIN=202.96.128.166
HWADDR=00:03:47:2C:D5:40
ONBOOT=yes
TYPE=Ethernet
2. 重启服务生效:service network restart
3. SSH
ssh面密码登陆:
配置问题
- 检查配置文件/etc/ssh/sshd_config是否开启了AuthorizedKeysFile选项
- 检查AuthorizedKeysFile选项指定的文件是否存在并内容正常
- ~权限设置为700
- ~/.ssh权限设置为700
- ~/.ssh/authorized_keys的权限设置为600
/etc/ssh/sshd_config
找到以下内容,并去掉注释符”#“
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
修改了配置文件需要重启sshd服务
$ service sshd restart
#mkdir .ssh
#cd .ssh
#ssh-keygen -t rsa -P '' -f id_rsa
#cat id_rsa.pub >> authorized_keys
目录权限问题
重启 ssh:sudo service sshd restart
在打开的终端页面,输入如下代码:
ssh user@hostname
注:上边代码为固定格式,其中
user 为 linux 服务器的管理员名称
hostname 为 linux 服务器的IP
利用ssh传输文件:
1、从服务器上下载文件
scp username@servername:/path/filename /var/www/local_dir(本地目录)
例如scp root@192.168.0.101:/var/www/test.txt
把192.168.0.101上的/var/www/test.txt 的文件下载到/var/www/local_dir(本地目录)
2、上传本地文件到服务器
scp /path/filename username@servername:/path
例如scp /var/www/test.php root@192.168.0.101:/var/www/
把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中
3、从服务器下载整个目录
scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录)
例如:scp -r root@192.168.0.101:/var/www/test /var/www/
4、上传目录到服务器
scp -r local_dir username@servername:remote_dir
例如:scp -r test root@192.168.0.101:/var/www/
把当前目录下的test目录上传到服务器的/var/www/ 目录
5.查看目录或文件:
ssh user@host command ls "/path/*.tgz"
3.Linux 源修改:
第一步:备份你的原镜像文件,以免出错后可以恢复。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum clean all
yum makecache
4.Linux 终端颜色
~/.bashrc
export LS_COLORS=$LS_COLORS:'di=1;33:' ;
Some nice color choices (in this case 0;35 it is purple) are:
Blue = 34
Green = 32
Light Green = 1;32
Cyan = 36
Red = 31
Purple = 35
Brown = 33
Yellow = 1;33
white = 1;37
Light Grey = 0;37
Black = 30
Dark Grey= 1;30
The first number is the style (1=bold),
followed by a semicolon, and then the actual number of the color,
possible styles are:
0 = default colour
1 = bold
4 = underlined
5 = flashing text
7 = reverse field
40 = black background
41 = red background
42 = green background
43 = orange background
44 = blue background
45 = purple background
46 = cyan background
47 = grey background
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background
All possible colors:
31 = red
32 = green
33 = orange
34 = blue
35 = purple
36 = cyan
37 = grey
90 = dark grey
91 = light red
92 = light green
93 = yellow
94 = light blue
95 = light purple
96 = turquoise
di=1;4;31;42
in your LS_COLORS variable would make directories appear
in bold underlined red text with a green background!
ou can also change other kinds of files when using the ls command by defining each kind with:
di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has 'x' set in permissions).
*.rpm = files with the ending .rpm
5. 禁用防火墙
centos 7:
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
之前的版本:
service iptables stop #停止
chkconfig iptables off #禁用
6. tree ,
yum install tree
0 0
- CentOS 6.8(32)相关操作
- Centos 7 相关操作与配置
- centos 7 防火墙操作的相关命令
- CentOS 时间相关操作,修改时间,同步时间等
- centos添加新的端口及防火墙相关操作
- centos操作
- CentOS 操作
- centos 操作
- centos下添加管理员组和添加管理员用户及相关操作
- CentOS 相关网址收集
- centos xen相关资料
- Centos的相关文档
- Centos 5.6 相关命令
- centos 网卡相关命令
- CentOS 相关服务
- centos 相关资料
- centos mysql 相关
- CENTOS相关软件下载
- xcode无限闪退ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-1215
- ScrollView嵌套RecyclerView时滑动出现的卡顿解决方案
- 窗口置顶之SetWindowPos与SetForegroundWindow的区别
- shader学习(9)——properties的使用
- 15.Unity3D商业游戏源码研究-变身吧主公-PanelShop
- CentOS 6.8(32)相关操作
- Android开发艺术探索 第2章 IPC机制 读书笔记
- JAVA远程获取linux系统的信息
- tips:pc初始化,ie兼容,手机兼容 问题汇总
- Jersey2.X 进行json转化 出现错误 MessageBodyWriter not found for media type=application/json
- ASC码表
- vultr洛杉矶机房使用感受
- 数组和对象的区别和联系
- OpenCV基本数据类型表示的范围大小