Prints the current working directory.
Example:
pwd
Lists files and directories in the current directory.
Syntax:
ls [options] [directory]
Examples:
- Current location available file/directory list
ls - Detailed view
ls -l - Show hidden files
ls -a - Human-readable sizes
ls -lh - Recursive listing
ls -R
Changes the current directory.
Syntax:
cd [directory]
Examples:
- Go to a specific folder
cd /home/user/documents - Move up one level
cd .. - Go to root
cd /
Creates a new directory.
Syntax:
mkdir [directory_name]
Examples:
- Create a single directory
mkdir new_folder - Create nested directories
mkdir -p parent/child/grandchild
Deletes an empty directory.
Syntax:
rmdir [directory_name]
Example:
rmdir old_folder
Removes files or directories.
Syntax:
rm [options] [file/directory]
Examples:
- Remove a file
rm file.txt - Remove a folder and its contents
rm -rf foldername
Creates an empty file.
Syntax:
touch [filename]
Example:
touch myfile.txt
Displays the contents of a file.
Syntax:
cat [filename]
Example:
cat file.txt
Copies files and directories.
Syntax:
cp [options] source destination
Examples:
- Copy a file
cp file.txt /backup/ - Copy a directory
cp -r myfolder newfolder
Moves or renames files and directories.
Syntax:
mv [source] [destination]
Examples:
- Rename a file
mv oldname.txt newname.txt - Move a file
mv file.txt /new/location/
Creates links between files.
Syntax:
ln [options] target link_name
Examples:
- Symbolic link
ln -s /path/to/file symlink - Hard link
ln /path/to/file hardlink
Displays the current date and time.
Syntax:
date
Example:
date
Shows how long the system has been running.
Syntax:
uptime
Example:
uptime
Displays system and kernel information.
Example:
uname -a
Displays the currently logged-in user.
Example:
whoami
Lists all logged-in users.
Example:
who
Displays user ID and group information.
Syntax:
id [username]
Example:
id user
Lists all running processes.
Example:
ps -aux
Shows real-time system statistics.
Syntax:
top
Example:
top
Displays memory and swap usage in a human-readable format.
Example:
free -h
Shuts down or reboots the system.
Syntax:
shutdown [options] [time]
Examples:
- Power off immediately
shutdown -P now - Restart immediately
shutdown -r now - Cancel scheduled shutdown
shutdown -c
Reboots the system.
Example:
reboot