Article directory
Preface
"I will share my learning experience regularly, and everyone is welcome to leave messages and communicate, so that we can learn and make progress together! Thank you for your support, and let's start this journey full of technical fun together!"
Series of articles
1. ls command
Syntax: ls [options][directory or file]
Function: For a directory, this command lists all subdirectories and files in the directory. For files, the file name is listed along with other information
Common options:
-a 列出目录下的所有文件,包括以 . 开头的隐含文件。
-d 将目录象文件一样显示,而不是显示其下的文件。 如:ls –d 指定目录
-i 输出文件的 i 节点的索引信息。 如 ls –ai 指定文件
-k 以 k 字节的形式表示文件的大小。ls –alk 指定文件
-l 列出文件的详细信息。
-n 用数字的 UID,GID 代替名称。 (介绍 UID, GID)
-F 在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通文件;“/”表示目录;“@”表
示符号链接;“|”表示FIFOs;“=”表示套接字(sockets)。(目录类型识别)
-r 对目录反向排序。
-t 以时间排序。
-s 在l文件名后输出该文件的大小。(大小排序,如何找到目录下最大的文件)
-R 列出所有子目录下的文件。(递归)
-1 一行只输出一个文件。
For example:
Show only filename attributesls
Show detailed file propertiesls - l
This operation can be abbreviated asll
The effect is the same
View hidden filesls -l -a
This operation can be written asls -la
orll -a
You can find that there are two more files in this operation.
and ..
, so what are these two files?
In Linux, files starting with .
are called hidden files, so when we create a new file (study material), we can add .
in front of the file, so that the roommate You won't be able to find your study materials unless he is in the paper.
In any directory in Linux, there will be two hidden directories by default .
and ..
.
indicates the current path (usually used to execute programs)
..
indicates the superior path
2.pwd
Syntax: pwd
Function: Display the path of the current directory
For example:
Display the path of the current directory
Importpwd
——cd a
——pwd
As shown in the result;
Similar to the following operations on Windows:
If you are careful, have you noticed that the delimiter in Windows is ‘\
, while the delimiter in Linux is /
. This needs to be noted!
Why do we need a path?
This is used by the system to identify a file. You can find it quickly if you know the path of the learning materials
3.cd command
Syntax: cd [directory name]
Function: Change the working directory. Change the current working directory to the specified directory.
Example:
cd .. : 返回上级目录
cd /home/litao/linux/ : 绝对路径
cd ../day02/ : 相对路径
cd ~:进入用户家目录(也就是whoami指的用户目录)
cd -:返回最近访问目录
For example:
Change working directory
Importls -l
———cd b
——ll
As shown in the result;
Importll
——cd a
——ll
——cd ..
——ll
The result is as shown;
Equivalent to the following operations on Windows
Open the folder:
4.whoami command
Grammar: whoami
Function: View users currently using the Linux system
For the root account: the default home directory/root - super administrator account
For ordinary users, the default home directory /home/xxx - the new user name a>
For example:
Enterwhoami
displays the following results;
Similar to the following operations in windows
Open Settings - Select Account Options - Select "Your Information"
You can also view it in a folder:
5. Reunderstand the instructions
1. The essence of instructions are programs - instructions, programs, and executable programs are all the same thing.
How can you see it?
Our icons on the desktop are actually shortcuts, and their true identities are executable files (
.exe
)
In the Liunx operating system we You can also query itself or other commands through thels-l
command.
So, what are installation and uninstallation doing?
Copy/delete the executable program to the path
6.which command
Syntax:witch
Function: Request the system to print out the command name I specified, in the path where the system is located
For example:
Enterwhich ls
The following results are displayed;
Then we can also execute this program through the path
Enter< /span>, and you can find that the path is the same to print At this time we can also Use to display the following results; —— Enter operation. As follows: operation alias is also a Linux command. Its function is to give aliases to other commands. For example, I named the here? So what is /usr/bin/ls
displays the following results;
alias
ls -a -l
nb
alias nb='ls -a -l'
nb
which
nb
Similar to the following operations in windows
7. touch command
Syntax: touch [options]… file…
Function: The touch command parameters can change the date and time, access time and change time of the document or directory, or create a new file that does not exist.
Common options:
-a 或--time=atime或--time=access或--time=use只更改存取时间。
-c 或--no-create 不建立任何文档。
-d 使用指定的日期时间,而非现在的时间。
-f 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。
-m 或--time=mtime或--time=modify 只更改变动时间。
-r 把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。
-t 使用指定的日期时间,而非现在的时间。
For example:
Create file operation:
Importll
——touch
——ll
As shown in the result;
8. mkdir command (important):
Syntax: mkdir [options] dirname…
Function: Create a directory named "dirname" in the current directory
Applicable objects: All users with permission to operate the current directory
Common options:
-p, --parents 可以是一个路径名称。此时若路径中的某些目录尚不存在,加上此选项后,系统将自动建立
好那些尚不存在的目录,即一次可以建立多个目录;
For example:
Create directory operation, create an empty directory by default
Importll
——mkdir
——ll
As shown in the result;
What if you want to create a non-empty directory containing directories at once?
Enter-p a/b/c
——tree a
Note:
tree
Instructions to make Linux print in tree form and print out the specified directory
If it cannot run, run the installation commandyum -y install tree
Similar to the following operations on Windows:
9. rmdir command
Syntax: rmdir [-p][dirName]
Function: Delete empty directories
Applicable objects: All users with permission to operate the current directory
Common options:
-p 当子目录被删除后如果父目录也变成空目录的话,就连带父目录一起删除。
For example:
Importll
——rmdir 123
——ll
As shown in the result;
If you want to delete an empty directory, we can use thermidr
command, but it will not work if it is non-empty.
So we generally use < /span>rm
Command
10.rm command (important)
Syntax: rm [-f-i-r-v][dirName/dir]
Applicable to: All users
Function: Files or directories can be deleted at the same time
Common options:
-f 即使文件属性为只读(即写保护),亦直接删除
-i 删除前逐一询问确认
-r 删除目录及其下所有文件
For example:
Transportationll
——rm 111.txt
——y
——ll
Showing Result;
rm will ask you whether to delete when deleting. At this time, entery
to delete it. Entern
to cancel the operation. Is there any problem? What about operations that don’t require asking?
Userm -f
(f
here means mandatory)
if you want to delete the directory Userm-r
(herer
means recursion), let's combine the inputrm -rf
and see if there is no query, and also The directory has been deleted.
注意
Never enter when using
rm-f
. It will directly delete the root directory of the Linux system without asking you. You will regret it. It’s useless. Sometimes when entering the deletion code, one accidentally puts an extra space in front of , and it’s all over. Because the code runs from front to back, the program will run first, so special attention should be paid here, so once there are uncertain files, it is better to back them up than delete them!rm-f
/
rm-f
Similar to the following operations on Windows:
andrm-f
are similar to windows shortcut keysshift+del
keys
Summarize
Today is the 365th day of joining csdn, and it is also the 30th day of working hard to become a big boss. This article commemorates that the road is long and long.
Tips
Thank you for reading my blog, I hope you can get some inspiration and help from it. If you enjoyed this blog, please share it with your friends and family, and please leave your comments and feedback. Your support is my motivation to continue sharing and creating. Thanks! Hope we can see each other again in a future blog. I wish you all the best and look forward to seeing you again!