红帽常用命令

来源:互联网 发布:windows xp字体库下载 编辑:程序博客网 时间:2024/04/30 12:37

1. 配置:
  #setup
2. 防护墙:
  #/sbin/service iptables start stop restart
3. ftp:
  #yum install vsftpd;
  #yum remove vsftpd;
  #/sbin/service vsftpd start stop restart;
  #vi /etc/vsftpd/vsftpd.conf
4. 重新获取ip:
  #dhclient -r
  #dhclient 
5. 用户操作
  #/usr/sbin/useradd yourname
  #/usr/bin/passwd yournam
6. 后台运行:
    $ ./test.sh &
  [1] 17208
  $ jobs -l
  [1]+ 17208 Running                 ./test.sh &
  $ ./test.sh
  [1]+  Stopped                 ./test.sh
  $ bg %1
  [1]+ ./test.sh &
  $ jobs -l
  [1]+ 22794 Running                 ./test.sh &
  $ echo $$
  21734
  $ nohup ./test.sh &
  [1] 29016
  $ ps -ef | grep test
  515      29710 21734  0 11:47 pts/12   00:00:00 /bin/sh ./test.sh
  515      29713 21734  0 11:47 pts/12   00:00:00 grep test
  $ setsid ./test.sh &
  [1] 409
  $ ps -ef | grep test
  515        410     1  0 11:49 ?        00:00:00 /bin/sh ./test.sh
  515        413 21734  0 11:49 pts/12   00:00:00 grep test
  $ ./test.sh &
  [1] 2539
  $ jobs -l
  [1]+  2539 Running                 ./test.sh &
  $ disown -h %1
  $ ps -ef | grep test
  515        410     1  0 11:49 ?        00:00:00 /bin/sh ./test.sh
  515       2542 21734  0 11:52 pts/12   00:00:00 grep test
  $ (./test.sh &)
  $ ps -ef | grep test
  515        410     1  0 11:49 ?        00:00:00 /bin/sh ./test.sh
  515      12483 21734  0 11:59 pts/12   00:00:00 grep test
  $ screen -dmS screen_test
  $ screen -list
  There is a screen on:
      27963.screen_test       (Detached)
  1 Socket in /tmp/uscreens/S-jiangfeng.
  $ screen -r screen_test
7.  nohup把程序默认输出到nohup.out里,可以自己设定:nohup test.sh > test.log &


8. date
  查看系统时间:
  # date
  设置系统时间
  # date --set “07/07/06 10:19" (月/日/年时:分:秒) 
 
9. hwclock/clock
  查看硬件时间
  # hwclock --show 或者# clock --show 
  设置硬件时间
  # hwclock --set --date="07/07/06 10:19" (月/日/年 时:分:秒) 或者# clock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)


10. 更改文件所有者和组别:
  chown nile filename
  chown -R nile dir
  chgrp nile filename
11. 查看硬盘分区
  df -lh
  fdisk -l
12. 查看cpu
  cat /proc/cpuinfo
13. 查看内存
  cat /proc/meminfo
14. 日志
  # cd /var/log 
  # less secure 
  或者 
  # less messages 
  最近登录的日志: 
  # last 
15. 查看目录大小
  #du -sh
  查看root下的文件大小并排序
  #du -sh /* | sort -n
  或
  #du -sm /* | sort -n

16.7z 支持中文压缩


支持 7Z,ZIP,Zip64,CAB,RAR,ARJ,GZIP,BZIP2,TAR,CPIO,RPM,ISO,DEB 压缩文件格式


安装: sudo apt-get install p7zip p7zip-full p7zip-rar


# 7z a yajiu.7z yajiu.jpg yajiu.png
这条命令是将yajiu.jpg和yajiu.png压缩成一个7z包
# 7z a yajiu.7z *.jpg
这条命令是将所有.jpg的文件压缩成一个7z包
# 7z a yajiu.7z yajiu
这条命令是将文件夹yajiu压缩成一个7z包
# 7z e yajiu.7z
这条命令是将yajiu.7z中的所有文件解压出来,e是解压到当前路径
# 7z x yajiu.7z
这条命令是将yajiu.7z中的所有文件解压出来,x是解压到压缩包命名的目录下

17. find命令

Find命令格式:find [<路径>] [匹配条件]
(1)从根目录开始查找文件名为passwd的文件。
root@Ubuntu:~# find / -name passwd
(2)查找/usr目录下前10天访问过的文件(仅第10天这一天)。
root@Ubuntu:~#find  /usr  –atime 10
3)查找/usr目录下前10天之前访问过的文件。
root@Ubuntu:~#find  /usr –atime  +10
(4)查找/usr目录下前10天之后访问过的文件。
root@Ubuntu:~#find  /usr –atime  -10
(5)列出当前目录下所有扩展名是“doc”的文件。
root@Ubuntu:~# find  -name  "*.doc“
6)查找目录/etc /home下文件大小小于4K的文件。
root@Ubuntu:~# find  /etc /home –size  -4K

find命令可接受的文件尺寸单位有字节(c),块(b,512字节),K(k,1024字节)等。


18. 用户管理

vi /etc/passwd

vi /etc/shadow

vi /etc/group

uersadd username

userdel username

passwd username

锁定账号 passwd -l username

解锁账号 passwd -u username

usermod username

groupadd groupname

groupmod groupname

groupdel groupname

原创粉丝点击