linux basic commands essays

cd(change directory)

Not with the parameters directly into the current user's home directory

The representative of the current directory

.. on behalf of parent directory

ls(list)

-l      显示文件详细信息

-a      显示隐藏文件

-S      以文件大小排序(由大至小)

-t      以时间排序

-r      对目录方向排序

-h      方便阅读文件大小(K M G)

touch

-a:或--time=atime或--time=access或--time=use  只更改存取时间;
-c:或--no-create  不建立任何文件;
-d:<时间日期> 使用指定的日期时间,而非现在的时间;
-f:此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题;
-m:或--time=mtime或--time=modify  只更该变动时间;
-r:<参考文件或目录>  把指定文件或目录的日期时间,统统设成和参考文件或目录的日期时间相同;
-t:<日期时间>  使用指定的日期时间,而非现在的时间;

-d: You can change the access time and time Recent changestouch -d "2019-8-2 12:00:00" 1.txt

Use stat + filenameView three times (access, alteration, modification) and file details

Time-related

date Check System Time

date -s Modify the system time

hwclock View the system bios hardware time

hwclock -w Synchronize system time to hardware time

hwclock -s Synchronize system time to hardware time

calView Calendar

cal + 年份Check the specified calendar year

mkdir(make directory)

Create a folder

-p Creating folders recursively

rm

Delete a file or directory
-r: recursive delete (delete subfolders)
-f: forcibly removed, do not need to confirm (the directory can not be used rmto delete, can be rmdirdeleted, if you want to use rmto delete need to add -rdeletion)

-r and -f can be used in conjunction with rm -rfsuchrm -rf /*

cat

cat command can be used to view the contents of the file

-n: Displays line numbers to view the file

-b: Display line numbers to view the document (blank lines are not numbered)

Binding redirector >can merge the two files into one

cat i.txt j.txt > k.txt

Use >>a file contents can be appended to another file

cat a.txt >> b.txt

more

To view the contents of the form to flip through a space or enterlook

less

And more, like, I do not know the difference that more support View the previous page, lessyou can scroll up and down arrows. lessWhen done need to press q(quit) key to exit

Head down from the file list view (the default view the first ten rows of the contents of the head)

-n + 数字Check before n -line content

head -n 5 /etc/passwd

Check /etc/passwdin before 5 line content

tail

Down from the end of the file list view (the default view the first ten rows of the contents of the tail)

-n + 数字After a review of n -line content

tail -n 5 /etc/passwd

Check /etc/passwdback in 5 line content

tailf或者tail -f 支持动态显示数据,通常来查看日志文件。
日志文件最下面的就是最新的信息。因此使用tail命令

cp(copy)

Copy command

-d:当复制符号连接时,把目标文件或目录也建立为符号连接,并指向与源文件或目录连接的原始文件或目录;
-f:强行复制文件或目录,不论目标文件或目录是否已存在;
-i:覆盖既有文件之前先询问用户;
-l:对源文件建立硬连接,而非复制文件;
-p:保留源文件或目录的属性;
-R/r:递归处理,将指定目录下的所有文件与子目录一并处理;
-s:对源文件建立符号连接,而非复制文件;
-u:使用这项参数后只会在源文件的更改时间较目标文件更新时或是名称相互对应的目标文件并不存在时,才复制文件;
-b:覆盖已存在的文件目标前将目标文件备份;
-v:详细显示命令执行的操作。

mv(move)

mv command to rename a file or directory, or move a file from one directory to another directory.

mv 剪切源位置 粘贴目标位置
You can modify the name when pasting target location, source name change

    -b  再覆盖文件前进行备份
    -v  显示执行过程

Guess you like

Origin www.cnblogs.com/xbroad/p/11289682.html