Summary of common commands in Shell
author| Genius idiot dream source| Blog Park
1 ls command: list files
ls -la Lists all files and folders in the current directory
ls a* Lists all files in the current directory that begin with the letter a
ls -l *.txt Lists all files in the current directory with the suffix txt
2 cp Command: Copy
cp a.txt b.txt : copy the contents of file a to file b
cp a.txt ./ test : copy file a to text directory
cp -a test test2: recursively copy all files (including hidden files) under the directory test to the new directory test2
3 cat command: view combined files
cat a.txt: View the contents of the file
cat a.txt >> b.txt: Combine the contents of file a to the end of the contents of file b
cat-n a.txt: View files and label them with line numbers
4 touch command: create file
touch a.txt: Create a txt file named a
5 rm command: delete files
rm-rf a.txt: Force deletion of file a.txt
tm-i a.txt: there will be a prompt before deleting the file. Are you sure to delete the file?
6 mkdir command: Create directory
mkdir test: Create a directory named test
7 rmdir command: delete directory
tmdir test: Delete a directory
8 echo, cat commands: add content
echo "hello world! " >> a.txt: Add content to file a
cat a.txt : You can add multiple lines to the end of the file itself
cat