Common Linux Commands – Part 1
1. Common Commands
/ # Enter the home directorymkdir # Create a folder (mkdir 12345)touch # Create a file (touch 1.txt)vi # Create a file and edit content (vi 1.txt, insert to input content, esc to stop, :wq to save and exit)sudo mv # Rename a file (sudo mv 1.txt 2.txt)echo # Write content to a file (echo "kaka">1.txt)cd etc # Enter the directorycd .. # Go back to the upper levelpwd # Display the current directory pathla -al or ll # View file permissionschmod # Change file permissions (chmod 777 /12345)chattr +i # Set a file to be unchangeable (chattr +i /12345)ls -a # Show hidden files (ls -a -l to display files in long format)ls -l # List files and information in long format (ll is shorthand)ls / # List all directories in the root directory (ls / -l to display directories in long format)ll | grep "^-" | wc -l # Count the number of files in the current directory (excluding files in subdirectories)ls -l | grep "^d" | wc -l # Count the number of folders in the current directorydu -sh # Check the size of a folderfind ./ -name "samba" # Show the directory where the file is locatedlocate samba # Find system-related samba strings cat passwd # View file content