Introduction
In this article, you will learn about frequently used Linux commands with examples.
Linux Commands
List
1) Show all files and directories.
Syntax
ls
2) List out all files including hidden files.
Syntax
ls -a
3) List the files in 'long format', which contains lots of useful information (size, last modified).
Syntax
ls -l
4) List out the files with details (timestamp and access details).
Syntax
ls -l
Directory
1) Creating directory with all permissions (Read, write, and execute).
Syntax
mkdir -m 777 <directory_name>
Example
mkdir -m 777 sample_folder
2) Delete the directory.
Syntax
rmdir <directory_name>
Example
rmdir sample_folder
3) Rename the directory.
Syntax
mv <directory_name> <new_directory_name>
Example
mv sample_folder test_folder
4) To change the current directory location.
Syntax
cd <directory_name>
Example
cd sample_folder (Switch to a subdirectory (of the current directory) named sample_folder)
cd .. (Move to the parent directory of the current directory)
cd /home/sample_folder (Switch to a directory named /home/sample_folder)
5) Find all of the files in the directory and all of its subdirectories.
Syntax
find <directory_name> -name <file_name> -print
Example
find . -name myfile.txt -print (Find in the current directory and its subdirectories)
find sample_folder -name myfile.txt -print (Find in the "sample_folder" directory and its subdirectories)
Files
1) Creating the blank files.
Syntax
touch <file_name>
touch <file_name_1> <file_name_2> #For creating multiple blank files
Example
touch sample.txt or touch sample.txt text.txt
2) Create a new file using cat command.
Syntax
cat <file_name>
Example
cat new_test.txt
Note: Awaits input from the user, type desired text, and press CTRL+D (hold down Ctrl key and type ‘d‘) to exit.
3) Delete the file.
Syntax
rm <file_name>
Example
rm sample.txt (Deletes the file named "sample.txt")
rm sample.txt test.txt (Deletes two files – "sample.txt" and "test.txt")
rm new* (Deletes all files that begin with the prefix "new")
4) Move the file from one directory to another directory.
Syntax

Join the conversation! Your thoughts help the community grow.