当前位置:网站首页>Rhcsa Road

Rhcsa Road

2022-07-06 20:17:00 Omniscient magical conch

the second day

cd Toggle directory

#cd   chang  directory
 Relative paths :  Start searching relative to the current path        cd   home
​
/      root directory             cd   /
~     Current user's home directory 
.     Current directory     
..    Top directory         cd  ../../..
-      Last switched path 

cd .. Represents a return to the previous level directory

cd ../.. Representatives return to the upper two levels , And so on

cd - Switch to the last directory you entered

su User switching

su    USERNAME      Switch to the specified user , The current path has not changed 
su      Switch to root user 
su  -l   USERNAME   ==   su   -   redhat
 Switch to the specified user , Change the current path and return to the current user's home directory 
​

Shortcut key

ctrl+c Terminate the execution of the current order

ctrl+l Clear the screen == clear

ls List commands ( Look at all the files in the directory )

-l     Long format displays the file and its properties    ls  -l     ==  ll  
-d   View the properties of the specified directory      ll -d /root   The list is /root Directory attribute information     ll -d   Displays the properties of the current directory      
-a    Displays all files in the specified directory, including hidden files and .  ..  Current directory and upper level directory   ls -l  -a   == ls -la == ll -a
-A   Displays all files in the specified directory, including hidden files 
-h    File size conversion 
-i     Display file inode Node number 
-R   Recursively display all files in the current directory and nested Directory 
choose
term
function
-l
Displays the details of files and directories in a long grid ,ls The command displays only the short format of the name by default .
-d
Displays information about the specified directory itself , Instead of displaying the information of each file and subdirectory in the directory .
-c
After sorting according to the modification time of the file , Display .
-h
Show the size of a directory or file in a more user-friendly way , The default size is in bytes , Use -h Option will be displayed as
KM Equal unit . This option requires and -l Options can be used in combination to reflect the results .
-R
Recursively displays all contents of the specified directory and its subdirectories .
-a
Display information about all subdirectories and files , Include name to “.” Hidden directories and hidden files at the beginning , And the current directory (
.
And the upper level directory (..) Information about
-A
And -a Options work similarly , However, it does not display... Representing the current directory “.” And... Representing the parent directory “..”.
-i
Show file index node number (inode). An index node represents a file , stay linux Is saved in the disk partition
All documents are assigned a number , Called the inode number inode.

linux The basic idea is that everything is a document -----7 File types

- Plain text file    
​
d  Directory file   
​
l  Soft link file ( Shortcut )
​
 b  Block device file  
​
 c Character device file 
​
 p Pipeline files 
​
 s socket Socket file  
​
2-11 character     Marked is the permission identifier 
 Second column :  Number of hard links 
 The third column :  Users 
 The fourth column :  Subordinate to the group 
 The fifth column :  file size 
 The sixth column : File creation time or modification time 
 The seventh column : file name 

interview ----- The difference between soft link and hard link

stay linux In the file system , A file stored in a partition is assigned a number no matter what type it is , Called the inode number inode.

(1) Symbolic links are also called soft links , And the original file is not a file . for example Windows Shortcut to ,

Characteristics of action : Find a file in the specified path and access it quickly and easily , Delete source file shortcut cannot be accessed

Create objects : Text files and directory files can be created , And can cross file systems

Create link file :ln -s The original document Link to the file

How to determine whether it is a linked file : l

(2) Hard links ,

Concept : Multiple filenames point to the same Inode

Characteristics of action : Prevent users from deleting by mistake , Backup ( Backup only for file names )

Create objects : Cannot create for catalog file , And can't cross file systems

Create a hard link : ln The original document A new file

Whether multiple file names point to the same node number , And whether the number of hard links has changed

touch FILENAME create a file

mkdir DIRNAME Create directory

rm FILENAME Delete file

rm -r DIRNAME Delete directory files

cat FILENAME see file

nano FILENAME Edit the file

[[email protected] ~]#touch   aaa   Created... In the current path aaa file 
[[email protected] ~]#ln  -s  aaa   a.lnk   Yes aaa File creation shortcut file is called a.lnk
[[email protected] ~]#nano   aaa    Edit file contents    ctrl-x -- y - enter
[[email protected] ~]#cat   aaa       see aaa The content of the document 
[[email protected] ~]#cat   a.lnk
[[email protected] ~]#rm  aaa       Delete aaa file 
[[email protected] ~]#rm a.lnk
[[email protected] ~]#mkdir   dir1    Create directory 
[[email protected] ~]#ln -s dir1  dir1.lnk
[[email protected] ~]#rm -r dir1
​
 notes :
[[email protected] ~]#ln -s  /root/dir   /dir1.lnk      take /root Under the dir Directory to create shortcut files in / Under the table of contents 
​
[[email protected] ~]#ln -s    dir    /dir2.lnk      There is a problem ( take /dir Directory to create shortcut files in / Under the table of contents )
[[email protected] ~]# ll /
lrwxrwxrwx.   1 root root    3 Feb 11 01:08 dir2.lnk -> dir
 Creating hard links is only possible for text pieces 
[[email protected] ~]# touch   b
[[email protected] ~]# ln b  bbb
[[email protected] ~]# ll -i
33951783 -rw-r--r--. 2 root root    0 Feb 11 01:14 b
33951783 -rw-r--r--. 2 root root    0 Feb 11 01:14 bbb

*** File system hierarchy FHS

date

clock

hwclock -s The system time is synchronized to the hardware time

hwclock -w Hardware time is synchronized to system time

timedatectl status

list-timezones

set-timezone

set -time

Document management order

touch Create a text file

stat FILENAME View the detailed properties of the file

touch [-option...] FILENAME...

touch FILE1 FILE2 FILE3

touch /{FILE1,FILE2,FILE3}

touch {a..c}{1..3} a1 a2 a3 b1 b2 b3 c1 c2 c3

mkdir Create directory

mkdir [-options..] DIRNAME

-p parents Specify the parent directory to create ( Create multi-level directories from left to right )

-v verbose Details Displays the detailed results of the creation

Create multi-level directory mkdir -pv /1/2/3/4/5

tree Tree display directory structure

rm Delete file

rm [-options] FILENMAE/DIRNAME...

-f force mandatory

-r recursive , Delete directory files recursively

rm FILE1 FILE2

rm f* Delete with f All the documents at the beginning

rm *.txt

rm * Delete all text files in the current directory

rm -f

rm -r d1

rm -rf dd1

du View the disk size occupied by system files KB

-a View the total size of all files in the specified directory , The size of each file on the disk

-s Only the disk size occupied by all files in the specified directory is displayed , Don't show subdirectories

-h The display size can be converted into units

mv Moving files

mv  [-options]    The source file name ...      The target path 
​
[[email protected] ~]# touch a
[[email protected] ~]# ll
-rw-r--r--. 1 root root    0 Feb 11 03:33 a
[[email protected] ~]# mv a  /
[[email protected] ~]# ll /
total 28
-rw-r--r--.   1 root root    0 Feb 11 03:33 a
 Move and rename 
[[email protected] ~]# mv f  /file    take f File move to / Directory and rename it file (file The file in / The directory does not exist )
 File rename 
[[email protected] test]# mv a aaa

cp Copy file

cp [-options] The source file name ... The target path

-r Recursively copy directory files

-p Copy the file and keep the original properties of the file

-a== -rp Copy the directory and keep the original properties of the directory file

[[email protected] test]# cp -p  /test/a  /pub     Copy /test/a File to  /pub Catalog , Copy and keep the original properties of the file 
[[email protected] test]# ll /pub
total 4
-rw-r--r--. 1 root root 10 Feb 11 03:25 a
[[email protected] test]# cp -rp /test/d1  /pub   
​
[[email protected] test]# cp /test/a   /pub/a.txt       Copy /test/a File to  /pub Directory and rename it a.txt
[[email protected] test]# cp -r /test/d1  /pub/dir1

wget Download the file

wget [-option...] URL

-P Specify the download file to the specified path

-b Put the download process in the background

-c Breakpoint continuation

-t Specify the number of download attempts

-r Download catalog file

-o

-O

[email protected] test]# wget http://mirrors.163.com/centos/8/infra/x86_64/infra-common/Packages/a/awscli-1.18.156-1.el8.noarch.rpm     --- hold awscli-1.18.156-1.el8.noarch.rpm  Download to current path 
​
[email protected] test]# wget http://mirrors.163.com/centos/8/infra/x86_64/infra-common/Packages/a/awscli-1.18.156-1.el8.noarch.rpm    -P   /pub  hold awscli-1.18.156-1.el8.noarch.rpm  Download to /pub Catalog 

原网站

版权声明
本文为[Omniscient magical conch]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131225546148.html