Here’s a detailed explanation of the commands you requested. These descriptions include their purposes, syntax, common options, and examples.
- Purpose: Creates new directories.
- Syntax:
mkdir [options] [directory_name]
- Options:
-p
: Create parent directories as needed (e.g., nested directories).
- Example:
mkdir new_folder
→ Creates a directory namednew_folder
.mkdir -p parent/child
→ Createsparent
andchild
directories if they don’t exist.
- Purpose: Creates empty files or updates timestamps of existing files.
- Syntax:
touch [file_name]
- Example:
touch file.txt
→ Creates an empty file namedfile.txt
.touch file1 file2
→ Creates two empty files,file1
andfile2
.
- Purpose: Changes the current working directory.
- Syntax:
cd [directory_path]
- Examples:
cd /home/user/documents
→ Moves to the specified directory.cd ..
→ Moves to the parent directory.cd ~
→ Moves to the home directory.
- Purpose: Lists files and directories in the current or specified directory.
- Syntax:
ls [options] [directory]
- Options:
-l
: Detailed list format (permissions, size, modification date).-a
: Shows hidden files (files starting with.
).-h
: Human-readable sizes.
- Examples:
ls
→ Lists files in the current directory.ls -la
→ Lists all files (including hidden) in detailed format.
- Purpose: Displays the full path of the current directory.
- Syntax:
pwd
- Example:
- If you’re in
/home/user/documents
,pwd
outputs/home/user/documents
.
- If you’re in
- Purpose: Deletes files or directories.
- Syntax:
rm [options] [file/directory]
- Options:
-r
: Remove directories and their contents recursively.-f
: Force deletion without confirmation.
- Examples:
rm file.txt
→ Deletesfile.txt
.rm -rf folder
→ Deletesfolder
and all its contents.
- Purpose: Copies files or directories.
- Syntax:
cp [options] [source] [destination]
- Options:
-r
: Recursively copy directories.-v
: Verbose output (show progress).
- Examples:
cp file1.txt file2.txt
→ Copiesfile1.txt
tofile2.txt
.cp -r source_folder target_folder
→ Copies a directory.
- Purpose: Moves or renames files or directories.
- Syntax:
mv [source] [destination]
- Examples:
mv file.txt /home/user/
→ Movesfile.txt
to the/home/user
directory.mv oldname.txt newname.txt
→ Renamesoldname.txt
tonewname.txt
.
- Purpose: Displays the contents of a file or concatenates multiple files.
- Syntax:
cat [file_name(s)]
- Examples:
cat file.txt
→ Displays the content offile.txt
.cat file1.txt file2.txt > combined.txt
→ Mergesfile1
andfile2
intocombined.txt
.
- Purpose: Views file contents one page at a time.
- Syntax:
less [file_name]
- Examples:
less file.txt
→ Opensfile.txt
for paginated viewing.- Use
q
to quit,Arrow Keys
for navigation.
- Purpose: Displays the first few lines of a file.
- Syntax:
head -n [number] [file_name]
- Example:
head -n 5 file.txt
→ Shows the first 5 lines offile.txt
.
- Purpose: Displays the last few lines of a file.
- Syntax:
tail -n [number] [file_name]
- Example:
tail -n 10 file.txt
→ Shows the last 10 lines offile.txt
.
- Purpose: Edit text files in a terminal.
- Syntax:
nano [file_name]
- Examples:
nano file.txt
→ Opensfile.txt
for editing.- Use
Ctrl + O
to save andCtrl + X
to exit.
- Purpose: Edit text files with advanced features.
- Syntax:
vim [file_name]
- Basics:
- Press
i
to enter insert mode. - Press
Esc
, type:wq
, and press Enter to save and exit.
- Press
- Purpose: Displays running processes.
- Syntax:
ps [options]
- Options:
aux
: Shows all processes with detailed info.
- Example:
ps aux
→ Lists all running processes.
- Purpose: Displays real-time information about system processes and resource usage.
- Syntax:
top
- Usage:
- Press
q
to quit.
- Press
- Purpose: Stops a process by its Process ID (PID).
- Syntax:
kill [PID]
- Examples:
kill 1234
→ Terminates the process with PID 1234.
- Purpose: Stops all processes with a specific name.
- Syntax:
killall [process_name]
- Example:
killall firefox
→ Stops all instances of Firefox.
- Purpose: Displays help documentation for commands.
- Syntax:
man [command_name]
- Example:
man ls
→ Displays the manual forls
.
- Purpose: Searches for a specific text pattern.
- Syntax:
grep [pattern] [file_name]
- Example:
grep "error" log.txt
→ Finds occurrences of "error" inlog.txt
.
Here’s a detailed explanation of the commands you requested. These descriptions include their purposes, syntax, common options, and examples.
- Purpose: Creates new directories.
- Syntax:
mkdir [options] [directory_name]
- Options:
-p
: Create parent directories as needed (e.g., nested directories).
- Example:
mkdir new_folder
→ Creates a directory namednew_folder
.mkdir -p parent/child
→ Createsparent
andchild
directories if they don’t exist.
- Purpose: Creates empty files or updates timestamps of existing files.
- Syntax:
touch [file_name]
- Example:
touch file.txt
→ Creates an empty file namedfile.txt
.touch file1 file2
→ Creates two empty files,file1
andfile2
.
- Purpose: Changes the current working directory.
- Syntax:
cd [directory_path]
- Examples:
cd /home/user/documents
→ Moves to the specified directory.cd ..
→ Moves to the parent directory.cd ~
→ Moves to the home directory.
- Purpose: Lists files and directories in the current or specified directory.
- Syntax:
ls [options] [directory]
- Options:
-l
: Detailed list format (permissions, size, modification date).-a
: Shows hidden files (files starting with.
).-h
: Human-readable sizes.
- Examples:
ls
→ Lists files in the current directory.ls -la
→ Lists all files (including hidden) in detailed format.
- Purpose: Displays the full path of the current directory.
- Syntax:
pwd
- Example:
- If you’re in
/home/user/documents
,pwd
outputs/home/user/documents
.
- If you’re in
- Purpose: Deletes files or directories.
- Syntax:
rm [options] [file/directory]
- Options:
-r
: Remove directories and their contents recursively.-f
: Force deletion without confirmation.
- Examples:
rm file.txt
→ Deletesfile.txt
.rm -rf folder
→ Deletesfolder
and all its contents.
- Purpose: Copies files or directories.
- Syntax:
cp [options] [source] [destination]
- Options:
-r
: Recursively copy directories.-v
: Verbose output (show progress).
- Examples:
cp file1.txt file2.txt
→ Copiesfile1.txt
tofile2.txt
.cp -r source_folder target_folder
→ Copies a directory.
- Purpose: Moves or renames files or directories.
- Syntax:
mv [source] [destination]
- Examples:
mv file.txt /home/user/
→ Movesfile.txt
to the/home/user
directory.mv oldname.txt newname.txt
→ Renamesoldname.txt
tonewname.txt
.
- Purpose: Displays the contents of a file or concatenates multiple files.
- Syntax:
cat [file_name(s)]
- Examples:
cat file.txt
→ Displays the content offile.txt
.cat file1.txt file2.txt > combined.txt
→ Mergesfile1
andfile2
intocombined.txt
.
- Purpose: Views file contents one page at a time.
- Syntax:
less [file_name]
- Examples:
less file.txt
→ Opensfile.txt
for paginated viewing.- Use
q
to quit,Arrow Keys
for navigation.
- Purpose: Displays the first few lines of a file.
- Syntax:
head -n [number] [file_name]
- Example:
head -n 5 file.txt
→ Shows the first 5 lines offile.txt
.
- Purpose: Displays the last few lines of a file.
- Syntax:
tail -n [number] [file_name]
- Example:
tail -n 10 file.txt
→ Shows the last 10 lines offile.txt
.
- Purpose: Edit text files in a terminal.
- Syntax:
nano [file_name]
- Examples:
nano file.txt
→ Opensfile.txt
for editing.- Use
Ctrl + O
to save andCtrl + X
to exit.
- Purpose: Edit text files with advanced features.
- Syntax:
vim [file_name]
- Basics:
- Press
i
to enter insert mode. - Press
Esc
, type:wq
, and press Enter to save and exit.
- Press
- Purpose: Displays running processes.
- Syntax:
ps [options]
- Options:
aux
: Shows all processes with detailed info.
- Example:
ps aux
→ Lists all running processes.
- Purpose: Displays real-time information about system processes and resource usage.
- Syntax:
top
- Usage:
- Press
q
to quit.
- Press
- Purpose: Stops a process by its Process ID (PID).
- Syntax:
kill [PID]
- Examples:
kill 1234
→ Terminates the process with PID 1234.
- Purpose: Stops all processes with a specific name.
- Syntax:
killall [process_name]
- Example:
killall firefox
→ Stops all instances of Firefox.
- Purpose: Displays help documentation for commands.
- Syntax:
man [command_name]
- Example:
man ls
→ Displays the manual forls
.
- Purpose: Searches for a specific text pattern.
- Syntax:
grep [pattern] [file_name]
- Example:
grep "error" log.txt
→ Finds occurrences of "error" inlog.txt
.