Commands List
File and Directory Operations:
ls (list): Lists directory contents.
Flags:
l (long): Detailed information (permissions, owner, size, date).
a (all): Show hidden files (starting with a dot).
h (human-readable): Show file sizes in KB, MB, GB.
Example: ls -l lists the current directory with detailed info.
cd (change directory): Changes the working directory.
Flags:
(previous directory): Go back to the previously visited directory.
Example: cd Desktop navigates to the "Desktop" directory.
pwd (print working directory): Prints the full path of the current directory.
Example: pwd shows the absolute path of your current location.
mkdir (make directory): Creates a new directory.
Flags:
p (parents): Creates non-existent parent directories required for the
specified directory.
Example: mkdir new_folder creates a new directory named "new_folder".
rm (remove): Removes files or directories.
Caution: Use with caution as deleted files are generally unrecoverable.
Flags:
r (recursive): Removes directories and all their contents.
f (force): Ignores errors like "file is open". Use with caution!
Example: rm file.txt removes the file "file.txt".
cp (copy): Copies files or directories.
Commands List 1
Flags:
r (recursive): Copies directories and their contents.
Example: cp file.txt new_folder copies "file.txt" to the directory
"new_folder".
mv (move or rename): Moves or renames files or directories.
Example: mv file.txt renamed_file.txt renames "file.txt" to
"renamed_file.txt".
touch (create or update timestamp): Creates an empty file or updates the
modification time of an existing file.
Example: touch new_file.txt creates an empty file named "new_file.txt".
cat (concatenate): Concatenates and displays the content of files.
Flags:
n (number): Number all output lines.
Example: cat file.txt displays the contents of "file.txt".
Text Processing:
head (head of file): Outputs the first part of a file.
Flags:
n (number): Specifies the number of lines to display.
Example: head -5 file.txt shows the first 5 lines of "file.txt".
tail (tail of file): Outputs the last part of a file.
Flags:
n (number): Specifies the number of lines to display.
f (follow): Continuously outputs the end of the file as it grows.
Example: tail -2 file.txt displays the last 2 lines of "file.txt".
sort (sort): Sorts lines of text files in various orders.
Flags:
n (numeric): Sorts lines numerically.
r (reverse): Sorts in reverse order.
Commands List 2
Example: sort file.txt sorts "file.txt" alphabetically.
uniq (unique): Reports or omits repeated lines in a file.
Flags:
c (count): Counts the occurrences of each line.
Example: uniq file.txt shows only unique lines in "file.txt".
wc (word count): Prints newline, word, and byte counts for files.
Example: wc file.txt displays the number of lines, words, and bytes in
"file.txt".
sed (stream editor): A stream editor for manipulating text files (filtering,
searching, replacing content). (Syntax is complex).
Example: sed 's/text1/text2/g' file.txt replaces all occurrences of "text1"
with "text2" in "file.txt".
*awk (pattern scanning and processing language
System Information:
uname (show system name): Prints system information like kernel version
and operating system name.
Flags:
a (all): Show all available information.
Example: uname -a displays details about the system.
hostname (print or set hostname): Prints or sets the hostname of the
system.
Flags:
s (set hostname): Set a new hostname.
Example: hostname shows the current hostname, hostname new_name sets
the hostname to "new_name".
df (disk free): Reports file system disk space usage.
Flags:
h (human-readable): Show sizes in human-readable format (KB,
MB, GB).
Commands List 3
Example: df -h displays disk usage information for all mounted
filesystems.
du (disk usage): Estimates file space usage.
Flags:
h (human-readable): Show sizes in human-readable format (KB,
MB, GB).
s (summarize): Display total size only.
Example: du -sh file.txt shows the size of "file.txt" in a human-readable
format.
free (free memory): Displays the amount of free and used memory in the
system.
Example: free shows available, used, and total memory.
top (top processes): Provides a dynamic view of running processes,
sorting them by CPU or memory usage.
ps (process status): Reports a snapshot of currently running processes.
Flags:
e (all processes): Show information about all processes.
f (full format): Display detailed information about processes.
Example: ps -ef shows a full listing of all running processes.
uptime (system uptime): Shows how long the system has been running.
System Management:
sudo (superuser do): Executes a command as another user, typically the
root user with administrative privileges. Use with caution!
Example: sudo apt update updates the package list with root privileges
(assuming you use apt for package management).
shutdown or reboot: Shuts down or restarts the system.
Flags:
h now (halt): Halt the system immediately.
r now (reboot): Reboot the system immediately.
Commands List 4
Example: sudo shutdown -h now halts the system immediately (requires root
privileges).
service or systemctl (control system services): Starts, stops, or restarts
system services.
Example: sudo systemctl start apache2 starts the Apache web server
(assuming it's called apache2 on your system).
journalctl (journal control): Queries and displays system logs.
Flags:
u (service unit): Show logs for a specific service.
f (follow): Continuously display new logs as they are written.
Example: journalctl -u apache2 -f follows logs for the Apache web server.
Network Operations:
ping (send echo request): Sends an ICMP ECHO_REQUEST to a network
host to test connectivity.
Flags:
c count (number of packets): Specify the number of ping packets to
send.
Example: ping -c 3 google.com pings google.com three times.
ifconfig or ip (interface configuration): Configures network interfaces (IP
addresses, subnet masks, etc.). (ifconfig may be deprecated on some
systems).
Example: ifconfig eth0 shows information about the network interface
eth0.
netstat (network statistics): Prints information about network connections,
routing tables, and network interfaces.
ssh (secure shell): Opens a secure shell connection to a remote server.
Example: ssh user@server_ip connects to the server with IP address
"server_ip" as user "user".
scp (secure copy): Securely copies files between local and remote
machines.
Commands List 5
Example: scp file.txt user@server_ip:/destination/folder copies "file.txt" to
the remote server in the specified folder.
wget or curl (download files): Downloads files from the internet.
Example: wget https://example.com/file.txt downloads the file "file
Commands List 6