Here’s a list of common commands along with their descriptions and usage examples:
ls
– List Directory Contents- Usage:
ls [options] [directory]
- Example:
ls -l /home
(lists all files in /home with detailed information)
- Usage:
cd
– Change Directory- Usage:
cd [directory]
- Example:
cd /home/user/Documents
(changes the current directory to /home/user/Documents)
- Usage:
pwd
– Print Working Directory- Usage:
pwd
- Example:
pwd
(displays the path of the current directory)
- Usage:
cat
– Concatenate and Display Files- Usage:
cat [options] [file]
- Example:
cat file.txt
(displays the content of file.txt)
- Usage:
cp
– Copy Files and Directories- Usage:
cp [options] source destination
- Example:
cp file1.txt file2.txt
(copies file1.txt to file2.txt)
- Usage:
mv
– Move or Rename Files and Directories- Usage:
mv [options] source destination
- Example:
mv file1.txt /home/user/Documents
(moves file1.txt to /home/user/Documents)
- Usage:
rm
– Remove Files or Directories- Usage:
rm [options] file
- Example:
rm file.txt
(removes file.txt)
- Usage:
mkdir
– Create a New Directory- Usage:
mkdir [options] directory
- Example:
mkdir new_folder
(creates a new directory named new_folder)
- Usage:
rmdir
– Remove Empty Directories- Usage:
rmdir [options] directory
- Example:
rmdir old_folder
(removes the directory old_folder if it’s empty)
- Usage:
grep
– Search Text Using Patterns- Usage:
grep [options] pattern [file]
- Example:
grep "hello" file.txt
(searches for the word “hello” in file.txt)
- Usage:
find
– Search for Files in a Directory Hierarchy- Usage:
find [path] [options] [expression]
- Example:
find /home -name "file.txt"
(finds all files named “file.txt” in /home)
- Usage:
chmod
– Change File Modes or Access Control Lists- Usage:
chmod [options] mode file
- Example:
chmod 755 script.sh
(sets the permission of script.sh to 755)
- Usage:
chown
– Change File Owner and Group- Usage:
chown [options] owner[:group] file
- Example:
chown user:group file.txt
(changes the owner of file.txt to ‘user’ and the group to ‘group’)
- Usage:
tail
– Output the Last Part of Files- Usage:
tail [options] [file]
- Example:
tail -n 5 file.txt
(displays the last 5 lines of file.txt)
- Usage:
head
– Output the First Part of Files- Usage:
head [options] [file]
- Example:
head -n 5 file.txt
(displays the first 5 lines of file.txt)
- Usage:
man
– Interface to the System Reference Manuals- Usage:
man [command]
- Example:
man ls
(displays the manual page for the ls command)
- Usage:
This is just a basic set of commands, and there are many more commands and options in Linux. For detailed information and more commands, you can always use the man
command followed by the command name to read the manual pages.