su 切换用户到root并在当前终端
1 2 3 | [jiel@jiel /]$ su Password: [root@jiel /] # |
su - 切换到root并开启一个新终端
1 2 3 | [jiel@jiel /]$ su - Password: [root@jiel ~] # |
su username 切换到指定用户,也适用-
1 2 3 4 5 6 | [jiel@jiel /]$ su aaa Password: [aaa@jiel /] # [jiel@jiel /]$ su - aaa Password: [aaa@jiel~] # |
sudo command 以root权限运行命令
1 2 3 | [jiel@jiel ~]$ sudo ifcfg [ sudo ] password for jiel: jiel is not in the sudoers file . This incident will be reported. |
passwd 修改当前用户密码
1 | [jiel@jiel ~]$ passwd |
id 显示当前用户信息
1 2 | [jiel@jiel ~]$ id uid=500(jiel) gid=500(jiel) groups =500(jiel) context=user_u:system_r:unconfined_t |
<ctrl+r> 查找历史信息
1 | (reverse-i-search)`ex': uid=500(jiel) gid=500(jiel) groups =500(jiel) context=user_u:system_r:unconfined_t |
1 | (reverse-i-search)`pa': passwd |
history 显示历史命令
1 2 3 4 5 6 | [jiel@jiel ~]$ history
1 ls
2 cd Desktop/
3 ls
4 cd /
5 cd mnt |
firefox $ 启动程序并在台运行
1 | [jiel@jiel ~]$ firefox $ |
jobs 查看后台运行的作业
1 2 | [root@localhost /] # jobs [1]+ Running firefox & |
sleep 5000 停止执行5000秒
<ctrl+z> 暂停当前程序
bg 2 启动后台编号的程序继续运行
fg 1 将后台编号的程序拉回前台
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [root@localhost /] # sleep 5000 [2]+ Stopped sleep 5000 [root@localhost /] # jobs [1]- Running firefox & [2]+ Stopped sleep 5000 [root@localhost /] # [root@localhost /] # bg 2 [2]- sleep 5000 & [root@localhost /] # jobs [1] Running firefox & [2]- Running sleep 5000 & [root@localhost /] #fg 1 firefox |
ls 查看当前目录
ll 查看当前目录以列表模式(同ls -l显示详细信息)
ls -a 显示隐藏
ls -R 递归显示子目录结构
ls -ld 显示目录和链接信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 name [jiel@jiel ~]$ ll total 23884 drwxr-xr-x 2 jiel jiel 4096 May 25 12:12 Desktop -rw-rw-r-- 1 jiel jiel 24410321 May 25 12:29 firefox-21.0. tar .bz2 -rw-rw-r-- 1 jiel jiel 0 May 25 13:53 name [jiel@jiel ~]$ ls -a . .dmrc .gnome2_private .name1 .. .eggcups .gstreamer-0.10 .nautilus .bash_history .esd_auth .gtkrc-1.2-gnome2 .recently-used.xbel .bash_logout firefox-21.0. tar .bz2 .ICEauthority .redhat .bash_profile .gconf .metacity .thumbnails .bashrc .gconfd .mozilla .Trash .config .gnome name Desktop .gnome2 .name [jiel@jiel ~]$ ls -R .: Desktop firefox-21.0. tar .bz2 name . /Desktop : [jiel@jiel ~]$ ls -ld drwx------ 17 jiel jiel 4096 May 25 13:55 . [jiel@jiel ~]$ |
cd 切换到目录
1 2 3 | [jiel@jiel ~]$ cd / [jiel@jiel /]$ cd mnt [jiel@jiel mnt]$ |
pwd 显示当前目录
1 2 | [jiel@jiel ~]$ pwd /home/jiel |
touch name 创建或更新一个文件,已存在文件是更新一个已存在文件
touch .name1 创建或更新一个隐藏文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | [jiel@jiel ~]$ touch name [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 name [jiel@jiel ~]$ touch .name [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 name [jiel@jiel ~]$ ll total 23884 drwxr-xr-x 2 jiel jiel 4096 May 25 12:12 Desktop -rw-rw-r-- 1 jiel jiel 24410321 May 25 12:29 firefox-21.0. tar .bz2 -rw-rw-r-- 1 jiel jiel 0 May 25 13:53 name [jiel@jiel ~]$ ls -a . .dmrc .gnome2_private .name1 .. .eggcups .gstreamer-0.10 .nautilus .bash_history .esd_auth .gtkrc-1.2-gnome2 .recently-used.xbel .bash_logout firefox-21.0. tar .bz2 .ICEauthority .redhat .bash_profile .gconf .metacity .thumbnails .bashrc .gconfd .mozilla .Trash .config .gnome name Desktop .gnome2 .name [jiel@jiel ~]$ |
file name查看文件信息
1 2 3 4 5 | [jiel@jiel ~]$ file Desktop/ Desktop/: directory [jiel@jiel ~]$ file firefox-21.0. tar .bz2 firefox-21.0. tar .bz2: bzip2 compressed data, block size = 900k [jiel@jiel ~]$ |
cp 源 目标 复制文件
cp -r 递归复制目录(一般于复制整个目录)
cp -v 显示复制过程
1 2 3 4 5 6 7 8 9 10 11 | [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 name [jiel@jiel ~]$ cp name /tmp [jiel@jiel ~]$ ls /tmp gconfd-jiel orbit-jiel vmware-jiel gconfd-root orbit-root vmware-root keyring-fUekZY ssh -KqJgik4764 vmware-root-799775590 mapping-jiel virtual-root.OWGCiJ VMwareTools-9.2.2-893683. tar .gz mapping-root vmware-config0 vmware-tools-distrib name VMwareDnD [jiel@jiel ~]$ |
mv 源 目标 移动或重命名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | [jiel@jiel ~]$ mv name /tmp [jiel@jiel ~]$ ls /tmp firefox-21.0. tar .bz2 name VMwareDnD gconfd-jiel orbit-jiel vmware-jiel gconfd-root orbit-root vmware-root keyring-fUekZY ssh -KqJgik4764 vmware-root-799775590 mapping-jiel virtual-root.OWGCiJ VMwareTools-9.2.2-893683. tar .gz mapping-root vmware-config0 vmware-tools-distrib [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 [jiel@jiel ~]$ cd /tmp [jiel@jiel tmp]$ ls firefox-21.0. tar .bz2 name VMwareDnD gconfd-jiel orbit-jiel vmware-jiel gconfd-root orbit-root vmware-root keyring-fUekZY ssh -KqJgik4764 vmware-root-799775590 mapping-jiel virtual-root.OWGCiJ VMwareTools-9.2.2-893683. tar .gz mapping-root vmware-config0 vmware-tools-distrib [jiel@jiel tmp]$ mv name name2 [jiel@jiel tmp]$ ls firefox-21.0. tar .bz2 name2 VMwareDnD gconfd-jiel orbit-jiel vmware-jiel gconfd-root orbit-root vmware-root keyring-fUekZY ssh -KqJgik4764 vmware-root-799775590 mapping-jiel virtual-root.OWGCiJ VMwareTools-9.2.2-893683. tar .gz mapping-root vmware-config0 vmware-tools-distrib [jiel@jiel tmp]$ |
rm 删除文件
rm -r 递归删除文件夹
rm -i 递归删除的同时询问要删除的每一个文件夹
em -f 强制删除不提醒任何信息(会覆盖i)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | [jiel@jiel tmp]$ ls firefox-21.0. tar .bz2 name2 VMwareDnD gconfd-jiel orbit-jiel vmware-jiel gconfd-root orbit-root vmware-root keyring-fUekZY ssh -KqJgik4764 vmware-root-799775590 mapping-jiel virtual-root.OWGCiJ VMwareTools-9.2.2-893683. tar .gz mapping-root vmware-config0 vmware-tools-distrib [jiel@jiel tmp]$ rm name2 [jiel@jiel tmp]$ ls firefox-21.0. tar .bz2 orbit-jiel vmware-jiel gconfd-jiel orbit-root vmware-root gconfd-root ssh -KqJgik4764 vmware-root-799775590 keyring-fUekZY virtual-root.OWGCiJ VMwareTools-9.2.2-893683. tar .gz mapping-jiel vmware-config0 vmware-tools-distrib mapping-root VMwareDnD [jiel@jiel tmp]$ rm vmware-jiel rm : cannot remove `vmware-jiel': Is a directory [jiel@jiel tmp]$ rm -r vmware-jiel [jiel@jiel tmp]$ ls firefox-21.0. tar .bz2 orbit-jiel vmware-root gconfd-jiel orbit-root vmware-root-799775590 gconfd-root ssh -KqJgik4764 VMwareTools-9.2.2-893683. tar .gz keyring-fUekZY virtual-root.OWGCiJ vmware-tools-distrib mapping-jiel vmware-config0 mapping-root VMwareDnD [jiel@jiel tmp]$ rm -ri vmware-root rm : descend into write-protected directory `vmware-root'? y rm : remove write-protected regular file `vmware-root /vmware-db .pl.5425'? y rm : cannot remove `vmware-root /vmware-db .pl.5425': Permission denied rm : remove write-protected regular file `vmware-root /vmware-db .pl.3785'? n rm : remove write-protected regular file `vmware-root /vmware-db .pl.3788'? n rm : remove write-protected regular file `vmware-root /vmware-db .pl.3712'? [jiel@jiel tmp]$ |
mkdir name 创建文件夹
rmdir name删除空文件夹(删除非空文件夹用rm -r)
1 2 3 4 5 6 7 | [jiel@jiel ~]$ mkdir jiel [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 jiel [jiel@jiel ~]$ rmdir jiel [jiel@jiel ~]$ ls Desktop firefox-21.0. tar .bz2 [jiel@jiel ~]$ |
cat name 查看文本文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | [jiel@jiel etc]$ cat a2ps.cfg # a2ps.cfg -*- Makefile -*- # # System configuration file for a2ps. # Copyright (c) 1988-1993 Miguel Santana # Copyright (c) 1995-2000 Akim Demaille, Miguel Santana # # # This file is part of a2ps. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # |