Common commands for Linux file management

Summary: We have to connect to Linux through the SSH protocol. Because Linux itself has its own SSH service -ls command to view directory information After seeing the picture, you basically understand that a separate ls is a file to view a folder, and ls -l can display detailed information, if it is ls -la or ll You can view detailed information including hidden files. If there is a d in front of it, it means that this is a folder. ls -R the file hierarchy under the aa/ aa folder Then we can pass l

we have to connect to Linux through the SSH protocol. Because Linux itself has its own SSH service, write the picture description

here

-ls command to view the directory information. Write the picture description
here

. After seeing the picture, you will basically understand. A

separate ls is to view the files of the folder, and ls -l can display detailed information. If it is ls -la or ll, you can view detailed information including hidden files. If there is a d in front of it, it means that this is a folder. ls -R aa/ the file hierarchy under the aa folder

Then we can use ls --help to see what other commands we have in our ls family.

Write the picture description here

-pwd View the current path
-mkdir Create a folder
mkdir -pa/b/c If the parent directory of the folder to be created does not exist, automatically create
rmdir Delete empty folders (only empty files can be deleted folder)
rm -r /a/b (delete non-empty folder)
rm -rf /a/b (delete folder)

write picture description here

Create file
touch a.avi Create an empty file
vi blabla.txt Edit a file with a text editor and save
echo "angelababy,zhen de hen xihuan ni" > qingshu.txt Redirection method, write the output on the left into the file on the right

If it is a > is directly overwritten, If it is >> then append.

echo "angelababy,zhen de hen xihuan ni" >> qingshu.txt For

example, this is to append a line after qingshu.txt.

Write the picture description here

Delete the file
rm filename (rm -r delete the folder rm -rf force delete the file or folder)
Move the file Modify the file name
mv a/wenjian1.txt b/file1.txt (Move the file and also modify the file Name)

copy the file cp srcFile destFile to

view the content of the text file
cat wodeqingshu.txt
more wodeqingshu.txt You can view it in pagination, click the space to turn a page
less wodeqingshu.txt Not only can paginate, but also can easily search, turn back and other operations, press Space to turn a page, press down to turn a line, press up to turn a line, gg can also go back to the top, GG will go to the bottom, and you can directly search for keywords.

View the 10 lines at the end of the file The log output by the

qingshu.txt  
program has extraordinary debug significance in production practice
Real-time refresh shows the tail of the file

tail -f user.log
head -20 wodeqingshu.txt View the first 20 lines of the

file File Archive (1: Pack – Archive 2: Compress)
1 Archive
tar -cvf zaqizaba.tar a.avi a.txt b.txt testdir/
Write image description here

2 Compress
gzip testdir.tar
write image description here

gzip file
bzip file

tar -czvf testdir.tar.gz testdir/
tar -xzvf testdir.tar.gz Extract to the current directory tar -zxvf
testdir.tar.gz - C Downloads/ Unzip to the designated Downloads directory Write the picture description

here


Use the Yunqi Community APP, comfortable~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326225676&siteId=291194637