“Linux常用命令”的版本间的差异

来自小能手俱乐部
跳到导航 跳到搜索
第34行: 第34行:


==== ls 用法示例 ====
==== ls 用法示例 ====
<syntaxhighlight lang="text">
[root@bogon ~]# ls
anaconda-ks.cfg  test.txt
[root@bogon ~]# ls -a
.  ..  anaconda-ks.cfg  .bash_logout  .bash_profile  .bashrc  .cshrc  .tcshrc  test.txt
[root@bogon ~]# ls -l
总用量 8
-rw-------. 1 root root 1269 9月  3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -lh
总用量 8.0K
-rw-------. 1 root root 1.3K 9月  3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -ll
总用量 8
-rw-------. 1 root root 1269 9月  3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -alh
总用量 28K
dr-xr-x---.  2 root root  130 9月  10 14:15 .
dr-xr-xr-x. 19 root root  253 9月  3 12:18 ..
-rw-------.  1 root root 1.3K 9月  3 20:01 anaconda-ks.cfg
-rw-r--r--.  1 root root  18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
-rw-r--r--.  1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -o
总用量 8
-rw-------. 1 root 1269 9月  3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -oh
总用量 8.0K
-rw-------. 1 root 1.3K 9月  3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root    5 9月  10 10:46 test.txt
</syntaxhighlight>


=== pwd —— Print Working Directory ===
=== pwd —— Print Working Directory ===

2021年9月10日 (五) 06:18的版本

ls ——List

ls 介绍

List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. 列出有关文件的信息(默认为当前目录)。如果没有指定-cftuvSUX或——Sort,则按字母顺序排序。

官方的说的很清楚,默认列出当前目录,所以可以列出其他目录或者路径下的文件信息或者目录信息。 比如:

$ls /etc/hosts
/etc/hosts

ls 参数格式

ls [OPTION]... [FILE]...

ls命令参数

-a  列出指定目录下的所有文件,包括隐藏文件
-c 使用最后一次更改文件状态以进行排序(-t)或长时间打印(-l)的时间
-h 与-l选项一起使用时,请使用单位后缀:Byte、Kilobyte、mete、gb、tb和Petabyte,以便使用以2为基数的大小将数字减少到3或更少
-l 长格式列表。(见下文)。如果输出到终端,则所有文件大小的总和将输出到长清单前面的一行中
-n 以数字形式显示用户和组id,而不是在长(-l)输出中转换为用户或组名。这个选项默认打开-l选项
-o 以长格式列出,但省略组id
-s 显示每个文件实际使用的文件系统块的数量,以512字节为单位,其中部分单元四舍五入为下一个整数值
-t 在按照字典顺序对操作数排序之前,先按修改的时间排序(最近修改的是first)
-u 使用最后一次访问的时间,而不是最后一次修改文件进行排序

ls 用法示例

[root@bogon ~]# ls
anaconda-ks.cfg  test.txt
[root@bogon ~]# ls -a
.  ..  anaconda-ks.cfg  .bash_logout  .bash_profile  .bashrc  .cshrc  .tcshrc  test.txt
[root@bogon ~]# ls -l
总用量 8
-rw-------. 1 root root 1269 9月   3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -lh
总用量 8.0K
-rw-------. 1 root root 1.3K 9月   3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -ll
总用量 8
-rw-------. 1 root root 1269 9月   3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -alh
总用量 28K
dr-xr-x---.  2 root root  130 9月  10 14:15 .
dr-xr-xr-x. 19 root root  253 9月   3 12:18 ..
-rw-------.  1 root root 1.3K 9月   3 20:01 anaconda-ks.cfg
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
-rw-r--r--.  1 root root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -o
总用量 8
-rw-------. 1 root 1269 9月   3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root    5 9月  10 10:46 test.txt
[root@bogon ~]# ls -oh
总用量 8.0K
-rw-------. 1 root 1.3K 9月   3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root    5 9月  10 10:46 test.txt

pwd —— Print Working Directory

pwd介绍

参数格式

pwd 用法示例

touch (change file timestamps)

touch介绍

touch参数格式

touch命令参数

touch用法示例

cat&tac (Concatenate FILE(s), or standard input, to standard output.)

cat介绍

cat 参数格式

cat命令参数

cat常用参数示例

mkdir —— Make Directory

mkdir介绍

mkdir参数格式

mkdir命令参数

mkdir常用参数示例

cd —— Change Directory

cd介绍

cd常用参数示例

rm&rmdir —— Remove Directory

rm介绍

rm参数格式

rm命令参数

rm常用参数示例

mv —— Move

mv介绍

mv参数格式

mv命令参数

mv常用参数示例

cp —— Copy

cp介绍

cp参数格式

cp命令参数

cp常用参数示例

echo

echo介绍

echo常用参数示例

head&tail

head介绍

head参数格式

head命令参数

head常用参数示例

more&less

more介绍

more参数格式

more命令参数

wc

wc介绍

wc参数格式

wc命令参数

wc常用参数示例

which

which介绍

which参数格式

which常用参数示例

whereis

whereis介绍

whereis参数格式

whereis命令参数

whereis常用参数示例

nl

nl介绍

nl参数格式

nl命令参数

nl常用参数示例

ps

ps介绍

ps参数格式

ps命令参数

ps常用参数示例

kill&killall

kill介绍

kill参数格式

kill命令参数

kill常用参数示例