linux 文件系统及基础命令 (亢龙有悔.)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 文件系统及基础命令 (亢龙有悔.)相关的知识,希望对你有一定的参考价值。
linux文件系统及基础命令
命令详解及范例:
1.pwd :此命令为显示工作目录
[[email protected] sysconfig]# pwd
/etc/sysconfig
2.echo :此命令为回显示命令
[[email protected] sysconfig]# echo $PATH
/usr/lib64/qt3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root
3.cd :此命令为切换命令
[[email protected] sysconfig]# cd
[[email protected] ~]# 此例为切换回家目录
[[email protected] etc]# cd ~
[[email protected] ~]# 此命令也是切换回家目录
[[email protected] home]# cd ~ming
[[email protected] ming]#此命令是切换到指定的用户的家目录
[[email protected] /]# cd -
/root
[[email protected] ~]# cd -
/
[[email protected] /]# cd -
/root
[[email protected] ~]# 在上一次所在目录与当前目录之间来回切换;
4.ls :
[[email protected] ~]# ls -a 显示所有文件,包括.和..在内的隐藏文件。
. anaconda-ks.cfg .bash_logout .bashrc .config .lesshst .tcshrc
.. .bash_history .bash_profile .cache .cshrc .ssh
[[email protected] ~]# ls -A 显示几乎所有的文件
anaconda-ks.cfg .bash_logout .bashrc .config .lesshst .tcshrc
.bash_history .bash_profile .cache .cshrc .ssh
[[email protected] ~]# ls -l 列出文件的详细信息
total 4
-rw-------. 1 root root 2639 Mar 4 21:30 anaconda-ks.cfg
[[email protected] ~]# ls -l
total 4
-rw-------. 1 root root 2639 Mar 4 21:30 anaconda-ks.cfg
[[email protected] ~]# ls -lh 此命令对数值进行单位换算
total 4.0K
-rw-------. 1 root root 2.6K Mar 4 21:30 anaconda-ks.cfg
[[email protected] ~]# ls -ld /etc 查看目录自身的属性
drwxr-xr-x. 119 root root 8192 Mar 6 11:52 /etc
ls -R 递归显示
[[email protected] /]# ls
bin dev home lib media opt root sbin sys usr wen
boot etc li lib64 mnt proc run srv tmp var
[[email protected] /]# ls -r 降序显示
wen usr sys sbin root opt media lib home dev bin
var tmp srv run proc mnt lib64 li etc boot
5.cat :
[[email protected] /]# cat /etc/fstab 显示文件内容
#
# /etc/fstab
# Created by anaconda on Fri Mar 4 13:14:59 2016
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2add5ce4-fbc0-4e3e-a6ca-4d43b052aa93 / xfs defaults 0 0
UUID=31fe4ea9-d043-424b-9d64-254e40193750 /boot xfs defaults 0 0
UUID=c9fc5e6b-639a-46dc-becd-f8d0d6aa6341 /usr xfs defaults 0 0
UUID=740e31fb-2fc2-4162-9fe5-171751ecd52e swap swap defaults 0 0
[[email protected] /]# cat -n /etc/fstab 对显示出的行进行编号
1
2 #
3 # /etc/fstab
4 # Created by anaconda on Fri Mar 4 13:14:59 2016
5 #
6 # Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
7 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
8 #
9 UUID=2add5ce4-fbc0-4e3e-a6ca-4d43b052aa93 / xfs defaults 0 0
10 UUID=31fe4ea9-d043-424b-9d64-254e40193750 /boot xfs defaults 0 0
11 UUID=c9fc5e6b-639a-46dc-becd-f8d0d6aa6341 /usr xfs defaults 0 0
12 UUID=740e31fb-2fc2-4162-9fe5-171751ecd52e swap swap defaults
[[email protected] /]# cat -E /etc/fstab 显示行结束符($)
$
#$
# /etc/fstab$
# Created by anaconda on Fri Mar 4 13:14:59 2016$
#$
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘$
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info$
#$
UUID=2add5ce4-fbc0-4e3e-a6ca-4d43b052aa93 / xfs defaults 0 0$
UUID=31fe4ea9-d043-424b-9d64-254e40193750 /boot xfs defaults 0 0$
UUID=c9fc5e6b-639a-46dc-becd-f8d0d6aa6341 /usr xfs defaults 0 0$
UUID=740e31fb-2fc2-4162-9fe5-171751ecd52e swap swap defaults 0 0$
6.tac :此命令时cat的逆序版
[[email protected] /]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Mar 4 13:14:59 2016
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2add5ce4-fbc0-4e3e-a6ca-4d43b052aa93 / xfs defaults 0 0
UUID=31fe4ea9-d043-424b-9d64-254e40193750 /boot xfs defaults 0 0
UUID=c9fc5e6b-639a-46dc-becd-f8d0d6aa6341 /usr xfs defaults 0 0
UUID=740e31fb-2fc2-4162-9fe5-171751ecd52e swap swap defaults 0 0
[[email protected] /]# tac /etc/fstab
UUID=740e31fb-2fc2-4162-9fe5-171751ecd52e swap swap defaults 0 0
UUID=c9fc5e6b-639a-46dc-becd-f8d0d6aa6341 /usr xfs defaults 0 0
UUID=31fe4ea9-d043-424b-9d64-254e40193750 /boot xfs defaults 0 0
UUID=2add5ce4-fbc0-4e3e-a6ca-4d43b052aa93 / xfs defaults 0 0
#
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
#
# Created by anaconda on Fri Mar 4 13:14:59 2016
# /etc/fstab
#
7.file :
[[email protected] /]# file /etc/fstab 此命令为查看文件的类型。
/etc/fstab: ASCII text
8.date: 此命令为系统时间显示命令
[[email protected] /]# date
Sun Mar 6 14:31:16 CST 2016
9.hwclock:此命令为硬件时间
[[email protected] /]# hwclock
Sun 06 Mar 2016 02:32:42 PM CST -0.649588 seconds
hwclock -s 指的是硬件与系统同步
hwclock -w 指的时系统与硬件同步
10.cal :查看日历的命令
[[email protected] /]# cal
March 2016
Su Mo Tu We Th Fr Sa
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
11.linux 系统上的文件的类型:
-:常规文件,有时使用f标识;
d:目录文件;
b:block;
c: character devices;
l:symbolic link files; 符号链接文件;
p:pipe,命名管道;
s:sokcet,套接字文件;
12.alias:进行命名别名的命令
[[email protected] /]# alias cle="clear"
[[email protected] /]# alias
alias cle=‘clear‘
alias cp=‘cp -i‘
alias egrep=‘egrep --color=auto‘
alias fgrep=‘fgrep --color=auto‘
alias grep=‘grep --color=auto‘
alias l.=‘ls -d .* --color=auto‘
alias ll=‘ls -l --color=auto‘
alias ls=‘ls --color=auto‘
alias mv=‘mv -i‘
alias rm=‘rm -i‘
alias which=‘alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde‘
[[email protected] /]# unalias cle 进行别名的取消命令
[[email protected] /]# cle
-bash: cle: command not found
13.
查看命令历史列表:
~]# history
命令用法:
history -c:清空命令历史;
history -d OFFSET:删除指定的条目;
-a 将当前缓冲的历史行追加到历史文件中
-n 从历史文件中读取所有未被读取的行
-r 读取历史文件并将内容追加到历史列表中
调用命令历史列表中的命令以重执行之目的:
!#:再一次执行历史列表中的第#条命令;
!!:再一次执行上一条命令;
!STRING:再一次执行命令历史列表中最近一个以指定的STRING开头的命令;
14.
shutdown:
shutdown [OPTIONS...] [TIME] [WALL...]
选项:
-h:关机
-r:重启
-c:取消尚未执行的关机或重启操作
TIME:
(1) HH:MM
(2) +m
15.
which:
which [OPTIONS] [PROGRAMS]
-a:显示所有匹配的程序文件,而非第一个;
[[email protected] /]# which -a /etc/host*
/usr/bin/which: no host.conf in (/etc)
/usr/bin/which: no hostname in (/etc)
/usr/bin/which: no hosts in (/etc)
/usr/bin/which: no hosts.allow in (/etc)
/usr/bin/which: no hosts.deny in (/etc
16.whereis:
whereis [options] name...
-b Search only for binaries 显示具体的路径
[[email protected] /]# whereis -b /etc
etc: /usr/local/etc
-m Search only for manuals
[[email protected] /]# whereis -m /etc
etc:[[email protected] /]
17.who:
who - show who is logged on
who [OPTION]...
-r:显示运行级别;
[[email protected] /]# who -r
run-level 3 2016-03-06 10:41
-b:系统本次启动的时间;
[[email protected] /]# who -b
system boot 2016-03-06 18:40
18 w:
w - Show who is logged on and what they are doing.
w [options] user [...]
[[email protected] /]# w
15:02:16 up 4:25, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
root tty1 13:57 1:04m 0.21s 0.21s -bash
root pts/0 192.168.1.110 13:58 0.00s 1.41s 0.01s
19 whoami:
etc:[[email protected] /]# whoami
root
whoami - print effective userid
本文出自 “李文明的博客” 博客,请务必保留此出处http://liwenming18.blog.51cto.com/11068518/1748058
以上是关于linux 文件系统及基础命令 (亢龙有悔.)的主要内容,如果未能解决你的问题,请参考以下文章