SlideShare a Scribd company logo
POWER TO EVERYONE
Unix
Command
Training
A beginner's guide
to acquiring
knowledge of Unix
commands
POWER TO EVERYONE
Unix
Command
Training
A beginner's guide
to acquiring
knowledge of Unix
commands
Introduction to
Unix Commands
Command Description Command Description
mkdir Create directories. tail Display the end of a file.
cd Change directory. head Display the beginning of a file.
pwd Print working directory. more Display output one screen at a time.
ls List directory contents. grep Search for patterns in files.
clear Clear the terminal screen. wc Count lines, words, and characters in a file.
cat Concatenate and display file content. rm Remove files and directories.
vi / vim Text editor for creating and editing files. cp Copy files and directories.
chmod Change file permissions. mv Move or rename files and directories.
du Estimate file and directory space usage. df Display disk space usage.
top/topas
Monitor system processes and resource
usage in real-time.
free Display system memory usage.
sh Execute a shell script. ./ Current directory.
ps Display running processes. kill Terminate processes.
ifconfig Configure network interfaces. telnet
Establish a command-line session with a
remote host.
netstat
Network statistics and connection
information.
ping Test network connectivity to a host.
tar Archive files. gzip Compress files.
gunzip Decompress gzip files. zcat Decompress and display compressed files.
nohup Run a command immune to hangups. sftp Secure File Transfer Protocol.
ssh Secure Shell remote login. find Search for files and directories.
locate
Find files by name quickly using a prebuilt
database.
uname
Print system information
Commands and their Descriptions:
Command: mkdir
Description: The `mkdir` command is used to create directories in a file system.
Useful Flags/Switches/Options:
Flag Description Example
-p Create parent directories if they do not exist. mkdir -p /path/to/new/directory
-m
Set permissions for the created directory using octal
notation.
mkdir -m 755 new_directory
-v Display a message for each created directory. mkdir -v directory1 directory2 directory3
--help Display the help information for the mkdir command. mkdir --help
--version Display the version information for the mkdir command. mkdir --version
Command: cd (Change Directory)
Description: Change the current working directory.
Useful Flags/Switches/Options:
Flag Description Example
cd
Without any arguments, cd alone takes you to your home
directory.
cd
cd /path/to/dir Use the absolute path to directly change to a specific directory. cd /var/www/html
cd .. Move up one level in the directory hierarchy. cd ..
cd - Switch back to the previous directory you were in. cd -
Command: pwd
Description: Displays the absolute path of the current working directory.
Example: `pwd`
Useful flags/switches/options:
Flag Description Example
-L Displays the logical path (resolved symbolic links) pwd -L
-P Displays the physical path (actual location) without symlinks pwd -P
-W Displays the working directory's path relative to the current directory pwd -W
--help Displays the help message with a brief description and options pwd --help
Command: `ls`
Description: List directory contents.
Useful Flags/Switches/Options:
Flag Description Example
-l Long format listing, displays detailed information about files and directories. ls -l
-a Include hidden files and directories starting with a dot (.). ls -a
-h Print file sizes in human-readable format (e.g., 1K, 5M, 2G). ls -lh
-S Sort files by size, largest first. ls -lS
-t Sort files by modification time, newest first. ls -lt
-R Recursively list directories and their contents. ls -R
Command: `clear`
Description: The `clear` command clears the terminal screen, providing a clean slate for new output or commands.
Example: `clear`
Useful flags/switches/options:
- No specific options are available for the `clear` command.
Command: cat
Description: `cat` (short for concatenate) is used to display the contents of a file on the standard output. It can also be
used to concatenate multiple files and create new files.
Useful Flags/Switches/Options:
Flag Description Example
-n Number the output lines. cat -n file.txt
-b Number the output lines, but only non-empty lines. cat -b file.txt
-s Squeeze multiple adjacent blank lines into a single blank line. cat -s file.txt
-E Display a dollar sign ($) at the end of each line. cat -E file.txt
Command: vi / vim: Text editor
Description: vi (Visual Editor) and its improved version vim (Vi IMproved) are powerful text editors used in various
Unix-like systems. They provide extensive functionality for creating, editing, and manipulating text files.
Useful Flags/Switches/Options:
Flag Description Example
vi filename Open a file for editing using vi/vim. vi myfile.txt
vim filename Open a file for editing using vim. vim myfile.txt
:w or :wq Save changes to the file and exit vi/vim. Press Esc, then :w or :wq and Enter
:q Quit vi/vim without saving changes. Press Esc, then :q and Enter
i Enter insert mode to start editing the file. Press i
x Delete the character at the cursor. Press x
/search_term Search for a specific term within the file. Press /, type search term, and Enter
n Move to the next occurrence of the search term. Press n
N Move to the previous occurrence of the search term. Press N
:set number Display line numbers in the file. Press Esc, then :set number and Enter
:syntax on Enable syntax highlighting for programming languages. Press Esc, then :syntax on and Enter
Command: chmod
Description: chmod is used to change the permissions (read, write, execute) of files and directories in Unix-like
operating systems.
Useful flags/switches/options:
Flag Description Example
-c Display a message for each file processed. chmod -c myfile.txt
-R Recursively change permissions for files and directories. chmod -R 755 mydirectory
+ Adds the specified permission(s) to the file or directory. chmod +x script.sh
- Removes the specified permission(s) from the file or directory. chmod -w myfile.txt
=
Sets the exact permission(s) specified, overriding any existing
permissions.
chmod =rwx myfile.txt
Numeric mode Represents permissions using numbers. chmod 644 myfile.txt
Command: tail
Description: The `tail` command displays the last part of a file, typically used to view the end of log files or
continuously monitor file updates.
Useful Flags/Switches/Options:
Flag Description Example
-n <num> or --
lines=<num>
Displays the last N lines of the file. Replace <num> with
the desired number of lines.
tail -n 10 file.txt - Displays the last 10
lines of the file.txt.
-f or --follow
Monitors the file and displays new lines as they are
appended to it.
tail -f log.txt - Continuously displays new
lines added to the log.txt file.
-q or --quiet
Suppresses the header information (file name) in the
output.
tail -q file.txt - Displays only the contents
of the file without the file name.
-v or --verbose
Displays the header information (file name) in the
output. This is the default behavior.
tail -v file.txt - Displays the contents of
the file along with the file name.
-r or --reverse Displays the lines of the file in reverse order.
tail -r file.txt - Displays the lines of file.txt
in reverse order.
Command: head
Description: Display the first 10 lines of a file.
Example: `head file.txt`
Useful Flags/Switches/Options:
Flag Description Example
-n Specify the number of lines to display. head -n 5 file.txt (Displays the first 5 lines)
-c Display the specified number of bytes instead of lines.
head -c 100 file.txt (Displays the first 100
bytes)
-q
Quiet mode. Suppress the display of file names when multiple files
are provided as arguments.
head -q file1.txt file2.txt (Displays the first
10 lines of both files without showing
their names)
-v
Verbose mode. Always display file names when multiple files are
provided as arguments.
head -v file1.txt file2.txt (Displays the first
10 lines of both files with their names)
--help
Display the help message for the head command, showing available
options.
head --help
Command: more
Description: `more` - Display file contents one page at a time.
Useful Flags/Switches/Options:
Flag Description Example
-n Specify the number of lines to display per page. more -n 10 file.txt - Displays 10 lines per page.
+<number> Start displaying from a specific line number. more +5 file.txt - Starts displaying from line 5.
+/pattern Start displaying from the first occurrence of a pattern. more +/keyword file.txt - Starts from "keyword".
q Quit the more command immediately. Pressing q exits more.
:f Display the current file name and line number. Pressing :f shows file name and line number.
/pattern Search for a specific pattern within the file. Typing /keyword searches for "keyword".
space Move forward one page. Pressing spacebar displays the next page.
b Move backward one page. Pressing b displays the previous page.
Command: grep
Description: The `grep` command is used for searching text patterns within files.
Useful Flags/Switches/Options:
Flag Description Example
-i Ignore case (case-insensitive search). grep -i "keyword" file.txt
-r or -R Perform a recursive search in directories. grep -r "keyword" directory/
-n Display line numbers along with matching lines. grep -n "keyword" file.txt
-v Invert the match and display lines that do not match. grep -v "keyword" file.txt
-w Match whole words only, ignoring partial matches. grep -w "word" file.txt
--exclude Exclude specific files or directories from the search. grep "keyword" --exclude="*.log" directory/
Command: wc
Description: `wc` counts the number of lines, words, and characters in a file or input.
Useful flags/options:
Flag Description Example
-l Count only the number of lines. wc -l file.txt
-w Count only the number of words. wc -w file.txt
-c Count only the number of characters. wc -c file.txt
-m
Count the number of characters,
including newline characters.
wc -m file.txt
-L Print the length of the longest line. wc -L file.txt
-help or --help
Display the help message with usage
instructions and available options.
wc --help
Command: rm
Description: Remove files and directories.
Useful Flags/Switches/Options:
Flag Description Example
-r Recursively remove directories and their contents. rm -r directory/
-f Forcefully remove files without prompting for confirmation. rm -f file.txt
-i Interactively prompt for confirmation before removing each file. rm -i file.txt
-v Verbose mode, display detailed information about the files. rm -v file.txt
-d Remove empty directories. rm -d empty_directory/
-rf
A combination of the -r and -f options, useful for forcefully removing
directories and their contents without prompting for confirmation.
rm -rf directory/
Command: `cp` (short for "copy")
Description: The `cp` command is used to copy files and directories in Linux/Unix systems.
Useful Flags/Switches/Options:
Flag Description Example
-r or -R Recursively copy directories and their contents. cp -r directory1 directory2
-i Prompt for confirmation before overwriting existing files. cp -i file1 file2
-u Copy only when the source file is newer than the destination file. cp -u file1 file2
-p
Preserve file attributes (permissions, timestamps, etc.) during the
copy.
cp -p file1 file2
Command: mv (Move/Rename)
Description: The `mv` command is used to move or rename files and directories.
Useful Flags/Switches/Options:
Flag Description Example
-i Prompt for confirmation before overwriting an existing file. mv -i file.txt new_location/
-u Update (move) only when the source is newer than the destination. mv -u source.txt destination/
-v Verbose mode, display detailed information about each file moved. mv -v file1.txt file2.txt
-n No-clobber, do not overwrite an existing file. mv -n file.txt new_location/
-b Create a backup of an existing file before moving it. mv -b file.txt new_location/
-t Specify the target directory for the moved file(s). mv -t destination/ file1.txt file2.txt
--help Display the help manual for the mv command. mv --help
Command: `du` (Disk Usage)
Description: The `du` command is used to estimate and display the disk space usage of files and directories.
Useful flags/switches/options:
Flag Description Example
-h Print sizes in human-readable format (e.g., 1K, 234M, 2G) du -h directory
-s Display the total sum of sizes for directories du -s directory
-a Include individual files in the output, in addition to directories du -a directory
-c Show a grand total of the disk usage at the end of the output du -c directory1 directory2
-x Skip directories on different file systems du -x directory
--exclude Exclude specific directories or files from disk usage calculation du --exclude=directory1 --exclude=file.txt
--max-depth Set the maximum depth of the directory tree to be displayed du --max-depth=3 directory
Command: df (Disk Free)
Description: Display disk space usage information.
Useful Flags/Switches/Options:
Flag Description Example
-h or --human-
readable
Display sizes in human-readable format (e.g., "10G" for gigabytes). df -h
-i or --inodes Display inode information (number of used and available inodes). df -i
-x or --exclude-type Exclude specific file system types from the output. df -x nfs
-t or --type Limit the output to specific file system types. df -t ext4
Command: top/topas
Description: The `top` or `topas` command is used to monitor system activity, providing real-time information about
CPU usage, memory usage, running processes, and other system statistics.
Useful Flags/Switches/Options:
Flag Description Example
-d Specify the refresh rate or delay between updates (in seconds). top -d 5 (Updates every 5 seconds)
-b Run top in batch mode, printing output once and exiting. top -b (Run top in batch mode)
-p Monitor specific process IDs (PIDs) instead of all processes.
top -p 1234 (Monitor process with PID
1234)
-n Set the number of iterations before top exits. top -n 10 (Exit after 10 iterations)
-s
Sort processes based on a specific field (e.g., %CPU, %MEM,
COMMAND).
top -s %CPU (Sort by CPU usage)
-R Reverse the default sorting order.
top -s %MEM -R (Sort by memory usage in
descending order)
Command: free
Description: Displays memory usage in kilobytes.
Useful Flags/Switches/Options:
Flag Description Example
-h Provides human-readable output with sizes in powers of 1024 (e.g., KB, MB, GB). free -h
-b Displays memory sizes in bytes. free -b
-k Displays memory sizes in kilobytes (default option). free -k
-m Displays memory sizes in megabytes. free -m
-g Displays memory sizes in gigabytes. free -g
Command: sh
Description: The `sh` command is a command-line interpreter for executing shell scripts.
Useful flags/switches/options:
Flag Description Example
-e Exit immediately if any command exits with a non-zero status sh -e script.sh
-x Print each command before executing it (enables script debugging) sh -x script.sh
-n Check syntax errors in the script without executing it sh -n script.sh
-r Prevent the shell from reading the user's initialization files sh -r script.sh
Command: ./ (dot slash)
Description: The `./` command allows you to run a script or program located in the current directory.
Example: Assuming you have a script named "script.sh" in the current directory, you can execute it using `./script.sh`.
Useful Flags/Switches/Options:
- There are no specific flags or options for `./` itself, as it is simply a way to execute a file in the current directory.
Note: Remember to make the script executable by setting the appropriate permissions using `chmod +x script.sh`
before executing it with `./`.
Command: nohup
Description: `nohup` runs a command that persists even after the user logs out.
Useful Flags/Switches/Options:
Flag Description Example
-n Redirects the output to a specified file instead of the default nohup.out file. nohup command > output.txt
-p Saves the process ID (PID) of the command to a specified file. nohup -p pid.txt command
-h Displays the usage information and exits. nohup -h
-v Prints the version information and exits. nohup -v
-c Specifies a shell command to be executed. nohup -c "echo Hello, World!"
Command: ps
Description: The `ps` command is used to display information about active processes running on the system.
Useful Flags/Switches/Options:
Flag Description Example
-e Show information about all processes. ps -e
-f Full format listing, providing detailed information about each process. ps -f
-u <username> Display processes owned by a specific user. ps -u john
-p <pid> Show information about a specific process identified by its process ID (PID). ps -p 1234
-o <format> Specify a custom output format for the process listing. ps -o pid,ppid,user,cmd
-aux
Display a comprehensive list of all processes with detailed information, including
those of other users.
ps -aux
-L Show threads associated with each process. ps -L
-C <name> Display processes with a specific command name. ps -C nginx
--forest Show processes in a tree-like format, indicating their parent-child relationships. ps --forest
Command: kill
Description: The kill command is used to terminate processes by sending signals to them. It allows you to stop
running processes manually.
Useful flags/switches/options:
Flag Description Example
-l or --list List all available signal names. kill -l
<signal> Specify the signal to send to the process. kill -SIGTERM <PID>
Commonly used signals include:
SIGTERM (15): Terminate the process gracefully.
SIGKILL (9): Forcefully terminate the process.
SIGQUIT (3): Quit the process and generate a core dump/thread dump.
<PID> Specify the process ID (PID) of the process to be terminated. kill 1234
-s <signal> Specify the signal to send using a numerical value. kill -s 15 1234
-a or --all Send the specified signal to all processes except kill itself. kill -SIGTERM -a
-3 or SIGQUIT Same as -s SIGQUIT or kill -SIGQUIT. Sends SIGQUIT to process.
Command: ifconfig
Description: Display and configure network interface parameters.
Useful Flags/Switches/Options:
Flag Description Example
ifconfig
Display the configuration of all active network
interfaces.
ifconfig
ifconfig <interface>
Display the configuration of a specific network
interface.
ifconfig eth0
ifconfig <interface> up Activate a network interface. ifconfig eth0 up
ifconfig <interface> down Deactivate a network interface. ifconfig eth0 down
ifconfig <interface> <IP_Address>
Assign a specific IP address to a network
interface.
ifconfig eth0 192.168.0.10
ifconfig -a
Display all network interfaces, including inactive
ones.
ifconfig -a
ifconfig -s Display a brief summary of network interfaces. ifconfig -s
ifconfig -v
Display verbose output with detailed
information.
ifconfig -v
Command: telnet
Description: Telnet is a network protocol used to establish a connection to a remote computer or server over a TCP/IP
network. It allows you to interact with the remote system through a command-line interface.
Useful flags/switches/options:
Flag Description Example
-l username Specify a username for login. telnet -l myusername remote-server.com
-p port
Specify a specific port to connect to (default is port 23 for
Telnet).
telnet remote-server.com 8080
-a Attempt automatic login. telnet -a remote-server.com
-e escapechar
Set the escape character used to enter telnet commands
during an active session.
telnet -e ^] remote-server.com
Command: netstat
Description: The `netstat` command is used to display network-related information in various forms.
Useful Flags/Switches/Options:
Flag Description Example
-a or --all Display all active connections, including listening ports. netstat -a
-t or --tcp Display TCP connections only. netstat -t
-u or --udp Display UDP connections only. netstat -u
-n or --numeric
Show numeric IP addresses and port numbers instead of resolving them to
hostnames.
netstat -n
-p or --programs Show the process ID (PID) and name associated with each connection. netstat -p
-l or --listening Display only listening (server) sockets. netstat -l
-r or --route Display the kernel's IP routing table. netstat -r
-s or --statistics Display network statistics and summary information. netstat -s
-c or --continuous Continuously display updated information. netstat -c
-h or --help Show the help message with command usage and available options. netstat -h
Command: ping
Description: The `ping` command sends ICMP Echo Request packets to a specified destination IP address or hostname
and waits for ICMP Echo Reply packets, allowing you to check network connectivity and measure round-trip time.
Useful Flags/Switches/Options:
Examples:
1. `ping google.com`: Send ICMP Echo Request packets to google.com to test network connectivity. Press Ctrl+C to
stop.
2. `ping -c 10 -i 2 example.com`: Send 10 ICMP Echo Request packets to example.com with a 2-second interval
between each packet.
Flag Description Example
-c count Specify the number of ICMP Echo Request packets to send. ping -c 5 google.com
-i interval Set the interval (in seconds) between successive packets. ping -i 1 example.com
-W timeout Set the timeout (in seconds) for each reply. ping -W 2 example.com
-v Verbose output, showing detailed information about each packet. ping -v example.com
Command: tar
Description: The `tar` command is used for archiving files and directories into a single file. It is often used for creating backups or
distributing multiple files as a single package.
Examples:
• Create a tar archive: tar -cf archive.tar file1.txt file2.txt directory/
• Extract files from a tar archive: tar -xf archive.tar
• Create a compressed tar archive using gzip: tar -czf archive.tar.gz directory/
• Create a compressed tar archive using bzip2: tar -cjf archive.tar.bz2 directory/
• List the contents of a tar archive: tar -tf archive.tar
• Extract files from a tar archive to a specific directory: tar -xf archive.tar -C /path/to/target
• Update an existing tar archive with newer files: tar -rf archive.tar newfile.txt
Useful Flags/Switches/Options :
Option Description Option Description
-c Create a new archive. -z Compress the archive using gzip.
-x Extract files from an archive. -j Compress the archive using bzip2.
-f Specify the archive file name. -t List the contents of an archive without extracting.
-v Verbose mode to display detailed output. -C Specify the target directory for extraction.
-u Update the archive with newer files only. -p Preserve file permissions, ownership, and timestamps.
-r Append files to an existing archive.
Command: gzip
Description: `gzip` is a command-line tool used for file compression in Linux and Unix-based systems. It reduces the
size of files, making them easier to store and transfer.
Useful Flags/Switches/Options:
Flag Description Example
-c
Write the compressed output to standard output without
modifying the original file.
gzip -c file.txt > compressed_file.gz
-d or --decompress Decompress a compressed file. gzip -d compressed_file.gz
-r or --recursive
Compress files in a directory and its subdirectories
recursively.
gzip -r directory
-k or --keep
Keep the original file after compression, preserving both the
compressed and uncompressed versions.
gzip -k file.txt
-t or --test
Test the integrity of a compressed file without decompressing
it.
gzip -t compressed_file.gz
-v or --verbose
Display verbose output, showing the compression ratio and
the file name.
gzip -v file.txt
Command: gunzip
Description: The `gunzip` command is used to decompress files compressed with the gzip compression algorithm.
Useful Flags/Switches/Options:
Flag Description Example
gunzip Decompresses files compressed with gzip.
-c
Writes the decompressed output to standard output without modifying the
original file.
gunzip -c file.gz
-k Keeps the original compressed file and creates a new decompressed file. gunzip -k file.gz
-f Forces the decompression even if the target file already exists. gunzip -f file.gz
-r Recursively decompresses files in a directory and its subdirectories. gunzip -r directory/
-l Lists information about the compressed files without decompressing them. gunzip -l file.gz
-v Displays verbose output with the decompression progress and details. gunzip -v file.gz
Command: zcat
Description: `zcat` allows you to view the contents of compressed files without actually decompressing them
permanently. It is typically used with files compressed using the gzip compression algorithm.
Useful Flags/Switches/Options:
- `-f`: Forces `zcat` to decompress files even if they do not have the `.gz` extension.
Example: `zcat -f file.txt`
- Examples:
1. `zcat file.txt.gz`: Display the contents of a compressed file `file.txt.gz`.
2. `zcat -f file.txt`: Decompress and display the contents of a file even if it does not have the `.gz` extension.
3. `zcat *.gz`: Display the contents of multiple compressed files in the current directory.
4. `zcat -f *.txt`: Decompress and display the contents of files with or without the `.gz` extension.
Command: sftp
Description: The `sftp` command is used for secure file transfer between a local host and a remote host over SSH
(Secure Shell) protocol. It provides an interactive interface for transferring files and performing various file operations
on the remote server.
Useful Flags/Switches/Options:
Flag Description Example
-P port Specify a custom SSH port for the connection. sftp -P 2222 user@host
-b batchfile Execute a batch file containing a sequence of sftp commands. sftp -b batchfile.txt user@host
-r Recursively transfer directories and their contents. sftp -r user@host:/remote/dir /local/dir
-i identity_file Specify a private key file for authentication. sftp -i private_key.pem user@host
-v
Verbose mode, displays detailed information about the file transfer
process.
sftp -v user@host
-q Quiet mode, suppresses progress and informational messages. sftp -q user@host
get Download a file from the remote server to the local machine. get remote_file.txt
put Upload a file from the local machine to the remote server. put local_file.txt
ls List files and directories on the remote server. ls
cd Change the remote server's working directory. cd /path/to/directory
Command: ssh (Secure Shell)
Description: ssh is used to establish a secure encrypted connection to a remote server or device over a network. It
provides a secure way to access and manage remote systems.
Useful flags/switches/options:
Flag Description Example
-p Specifies the port number to connect to the remote server. ssh -p 2222 username@remote_server
-i Specifies the identity file (private key) for public key authentication.
ssh -i /path/to/private_key
username@remote_server
-l Specifies the username to use for the remote connection. ssh -l username remote_server
-X
Enables X11 forwarding, allowing the remote server to display
graphical applications on the local machine.
ssh -X username@remote_server
-L
Sets up local port forwarding, allowing connections to a local port to
be forwarded to a remote server.
ssh -L 8080:localhost:80
username@remote_server
-R
Sets up remote port forwarding, allowing connections to a remote
port to be forwarded to a local server.
ssh -R 2222:localhost:22
username@remote_server
-C
Enables compression for the SSH connection, reducing bandwidth
usage.
ssh -C username@remote_server
-N
Requests an SSH connection without executing any remote
commands.
ssh -N -L 8080:localhost:80
username@remote_server
Command: find
Description: Search for files and directories recursively based on specified criteria.
Useful Flags/Switches/Options:
Flag Description Example
-name Search for files/directories with a specific name or pattern find /path/to/search -name "*.txt"
-type Filter by file type find /path/to/search -type f
-size Search based on file size find /path/to/search -size +1M
-mtime Search based on file modification time find /path/to/search -mtime +7
-exec Execute a command on each found file or directory
find /path/to/search -name "*.txt" -
exec ls -l {} ;
-delete Delete files or directories that match the search criteria
find /path/to/search -name "*.txt" -
delete
Command: locate
Description: `locate` quickly finds files by name using a prebuilt database.
Useful Flags/Options:
Flag Description Example
-i Perform a case-insensitive search. locate -i filename
-r Use regular expressions for pattern matching. locate -r '^file.*.txt$'
-l Limit the number of results displayed. locate -l 10 filename
-c Count the number of matching files. locate -c filename
-n Limit the number of database matches scanned. locate -n 100 filename
-b Match only the basename of the file. locate -b filename
-e Treat the search pattern as an exact match. locate -e "exact_filename"
-q Quiet mode, suppress error messages. locate -q filename
Command: uname
Description: Print system information.
Useful Flags/Options:
Flag Description Example
-a or --all Print all available information. uname -a
-s or --kernel-name Print the kernel name. uname -s
-n or --nodename Print the network node hostname. uname -n
-r or --kernel-release Print the kernel release. uname -r
-v or --kernel-version Print the kernel version. uname -v
-m or --machine Print the machine hardware name. uname -m
-p or --processor Print the processor type or "unknown". uname -p
-i or --hardware-platform Print the hardware platform. uname -i
-o or --operating-system Print the operating system. uname -o
Command:
Thank You
Thank You

More Related Content

PDF
Linux Command Line - By Ranjan Raja
Ranjan Raja
 
PDF
Linux file commands and shell scripts
PrashantTechment
 
DOCX
Directories description
Dr.M.Karthika parthasarathy
 
PPTX
Basic Linux Commands with syntax and functions
SasiBhushan22
 
PPTX
Basic Linux Commands and implementation with Examples
SasiBhushan22
 
TXT
An a z index of the bash commands
Ben Pope
 
PPTX
Linux System commands Essentialsand Basics.pptx
mba1130feb2024
 
PDF
linux commands.pdf
amitkamble79
 
Linux Command Line - By Ranjan Raja
Ranjan Raja
 
Linux file commands and shell scripts
PrashantTechment
 
Directories description
Dr.M.Karthika parthasarathy
 
Basic Linux Commands with syntax and functions
SasiBhushan22
 
Basic Linux Commands and implementation with Examples
SasiBhushan22
 
An a z index of the bash commands
Ben Pope
 
Linux System commands Essentialsand Basics.pptx
mba1130feb2024
 
linux commands.pdf
amitkamble79
 

Similar to Unix Trainning Doc.pptx (20)

PPT
Examples -partII
Kedar Bhandari
 
PPTX
OS-Module 2 Linux Programming Important topics
JithinS34
 
PDF
Workshop on command line tools - day 1
Leandro Lima
 
PPT
Linux ppt
Sanmuga Nathan
 
DOCX
40 basic linux command
Teja Bheemanapally
 
DOCX
40 basic linux command
Teja Bheemanapally
 
PPT
2.Utilities.ppt
SupunAsanga2
 
PDF
unix_ref_card.pdf
GiovaRossi
 
PDF
unix_ref_card.pdf
GiovaRossi
 
PDF
unix_ref_card.pdf
GiovaRossi
 
PPT
Linux
HAINIRMALRAJ
 
ODP
Linux
merlin deepika
 
ODP
Linux
merlin deepika
 
PDF
Lesson 3 Working with Files in Linux
Sadia Bashir
 
DOCX
Unix commands
Divya_Gupta19
 
DOCX
Perintah dasar terminal kali linux
Faizalguswanda
 
PDF
KALI-LINUX-COMMANDS.pdf.................
salmannawaz6566504
 
PPT
workshop_1.ppt
hazhamina
 
Examples -partII
Kedar Bhandari
 
OS-Module 2 Linux Programming Important topics
JithinS34
 
Workshop on command line tools - day 1
Leandro Lima
 
Linux ppt
Sanmuga Nathan
 
40 basic linux command
Teja Bheemanapally
 
40 basic linux command
Teja Bheemanapally
 
2.Utilities.ppt
SupunAsanga2
 
unix_ref_card.pdf
GiovaRossi
 
unix_ref_card.pdf
GiovaRossi
 
unix_ref_card.pdf
GiovaRossi
 
Lesson 3 Working with Files in Linux
Sadia Bashir
 
Unix commands
Divya_Gupta19
 
Perintah dasar terminal kali linux
Faizalguswanda
 
KALI-LINUX-COMMANDS.pdf.................
salmannawaz6566504
 
workshop_1.ppt
hazhamina
 
Ad

Recently uploaded (20)

PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Landforms and landscapes data surprise preview
jpinnuck
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Ad

Unix Trainning Doc.pptx

  • 1. POWER TO EVERYONE Unix Command Training A beginner's guide to acquiring knowledge of Unix commands
  • 2. POWER TO EVERYONE Unix Command Training A beginner's guide to acquiring knowledge of Unix commands
  • 4. Command Description Command Description mkdir Create directories. tail Display the end of a file. cd Change directory. head Display the beginning of a file. pwd Print working directory. more Display output one screen at a time. ls List directory contents. grep Search for patterns in files. clear Clear the terminal screen. wc Count lines, words, and characters in a file. cat Concatenate and display file content. rm Remove files and directories. vi / vim Text editor for creating and editing files. cp Copy files and directories. chmod Change file permissions. mv Move or rename files and directories. du Estimate file and directory space usage. df Display disk space usage. top/topas Monitor system processes and resource usage in real-time. free Display system memory usage. sh Execute a shell script. ./ Current directory. ps Display running processes. kill Terminate processes. ifconfig Configure network interfaces. telnet Establish a command-line session with a remote host. netstat Network statistics and connection information. ping Test network connectivity to a host. tar Archive files. gzip Compress files. gunzip Decompress gzip files. zcat Decompress and display compressed files. nohup Run a command immune to hangups. sftp Secure File Transfer Protocol. ssh Secure Shell remote login. find Search for files and directories. locate Find files by name quickly using a prebuilt database. uname Print system information Commands and their Descriptions:
  • 5. Command: mkdir Description: The `mkdir` command is used to create directories in a file system. Useful Flags/Switches/Options: Flag Description Example -p Create parent directories if they do not exist. mkdir -p /path/to/new/directory -m Set permissions for the created directory using octal notation. mkdir -m 755 new_directory -v Display a message for each created directory. mkdir -v directory1 directory2 directory3 --help Display the help information for the mkdir command. mkdir --help --version Display the version information for the mkdir command. mkdir --version
  • 6. Command: cd (Change Directory) Description: Change the current working directory. Useful Flags/Switches/Options: Flag Description Example cd Without any arguments, cd alone takes you to your home directory. cd cd /path/to/dir Use the absolute path to directly change to a specific directory. cd /var/www/html cd .. Move up one level in the directory hierarchy. cd .. cd - Switch back to the previous directory you were in. cd -
  • 7. Command: pwd Description: Displays the absolute path of the current working directory. Example: `pwd` Useful flags/switches/options: Flag Description Example -L Displays the logical path (resolved symbolic links) pwd -L -P Displays the physical path (actual location) without symlinks pwd -P -W Displays the working directory's path relative to the current directory pwd -W --help Displays the help message with a brief description and options pwd --help
  • 8. Command: `ls` Description: List directory contents. Useful Flags/Switches/Options: Flag Description Example -l Long format listing, displays detailed information about files and directories. ls -l -a Include hidden files and directories starting with a dot (.). ls -a -h Print file sizes in human-readable format (e.g., 1K, 5M, 2G). ls -lh -S Sort files by size, largest first. ls -lS -t Sort files by modification time, newest first. ls -lt -R Recursively list directories and their contents. ls -R
  • 9. Command: `clear` Description: The `clear` command clears the terminal screen, providing a clean slate for new output or commands. Example: `clear` Useful flags/switches/options: - No specific options are available for the `clear` command.
  • 10. Command: cat Description: `cat` (short for concatenate) is used to display the contents of a file on the standard output. It can also be used to concatenate multiple files and create new files. Useful Flags/Switches/Options: Flag Description Example -n Number the output lines. cat -n file.txt -b Number the output lines, but only non-empty lines. cat -b file.txt -s Squeeze multiple adjacent blank lines into a single blank line. cat -s file.txt -E Display a dollar sign ($) at the end of each line. cat -E file.txt
  • 11. Command: vi / vim: Text editor Description: vi (Visual Editor) and its improved version vim (Vi IMproved) are powerful text editors used in various Unix-like systems. They provide extensive functionality for creating, editing, and manipulating text files. Useful Flags/Switches/Options: Flag Description Example vi filename Open a file for editing using vi/vim. vi myfile.txt vim filename Open a file for editing using vim. vim myfile.txt :w or :wq Save changes to the file and exit vi/vim. Press Esc, then :w or :wq and Enter :q Quit vi/vim without saving changes. Press Esc, then :q and Enter i Enter insert mode to start editing the file. Press i x Delete the character at the cursor. Press x /search_term Search for a specific term within the file. Press /, type search term, and Enter n Move to the next occurrence of the search term. Press n N Move to the previous occurrence of the search term. Press N :set number Display line numbers in the file. Press Esc, then :set number and Enter :syntax on Enable syntax highlighting for programming languages. Press Esc, then :syntax on and Enter
  • 12. Command: chmod Description: chmod is used to change the permissions (read, write, execute) of files and directories in Unix-like operating systems. Useful flags/switches/options: Flag Description Example -c Display a message for each file processed. chmod -c myfile.txt -R Recursively change permissions for files and directories. chmod -R 755 mydirectory + Adds the specified permission(s) to the file or directory. chmod +x script.sh - Removes the specified permission(s) from the file or directory. chmod -w myfile.txt = Sets the exact permission(s) specified, overriding any existing permissions. chmod =rwx myfile.txt Numeric mode Represents permissions using numbers. chmod 644 myfile.txt
  • 13. Command: tail Description: The `tail` command displays the last part of a file, typically used to view the end of log files or continuously monitor file updates. Useful Flags/Switches/Options: Flag Description Example -n <num> or -- lines=<num> Displays the last N lines of the file. Replace <num> with the desired number of lines. tail -n 10 file.txt - Displays the last 10 lines of the file.txt. -f or --follow Monitors the file and displays new lines as they are appended to it. tail -f log.txt - Continuously displays new lines added to the log.txt file. -q or --quiet Suppresses the header information (file name) in the output. tail -q file.txt - Displays only the contents of the file without the file name. -v or --verbose Displays the header information (file name) in the output. This is the default behavior. tail -v file.txt - Displays the contents of the file along with the file name. -r or --reverse Displays the lines of the file in reverse order. tail -r file.txt - Displays the lines of file.txt in reverse order.
  • 14. Command: head Description: Display the first 10 lines of a file. Example: `head file.txt` Useful Flags/Switches/Options: Flag Description Example -n Specify the number of lines to display. head -n 5 file.txt (Displays the first 5 lines) -c Display the specified number of bytes instead of lines. head -c 100 file.txt (Displays the first 100 bytes) -q Quiet mode. Suppress the display of file names when multiple files are provided as arguments. head -q file1.txt file2.txt (Displays the first 10 lines of both files without showing their names) -v Verbose mode. Always display file names when multiple files are provided as arguments. head -v file1.txt file2.txt (Displays the first 10 lines of both files with their names) --help Display the help message for the head command, showing available options. head --help
  • 15. Command: more Description: `more` - Display file contents one page at a time. Useful Flags/Switches/Options: Flag Description Example -n Specify the number of lines to display per page. more -n 10 file.txt - Displays 10 lines per page. +<number> Start displaying from a specific line number. more +5 file.txt - Starts displaying from line 5. +/pattern Start displaying from the first occurrence of a pattern. more +/keyword file.txt - Starts from "keyword". q Quit the more command immediately. Pressing q exits more. :f Display the current file name and line number. Pressing :f shows file name and line number. /pattern Search for a specific pattern within the file. Typing /keyword searches for "keyword". space Move forward one page. Pressing spacebar displays the next page. b Move backward one page. Pressing b displays the previous page.
  • 16. Command: grep Description: The `grep` command is used for searching text patterns within files. Useful Flags/Switches/Options: Flag Description Example -i Ignore case (case-insensitive search). grep -i "keyword" file.txt -r or -R Perform a recursive search in directories. grep -r "keyword" directory/ -n Display line numbers along with matching lines. grep -n "keyword" file.txt -v Invert the match and display lines that do not match. grep -v "keyword" file.txt -w Match whole words only, ignoring partial matches. grep -w "word" file.txt --exclude Exclude specific files or directories from the search. grep "keyword" --exclude="*.log" directory/
  • 17. Command: wc Description: `wc` counts the number of lines, words, and characters in a file or input. Useful flags/options: Flag Description Example -l Count only the number of lines. wc -l file.txt -w Count only the number of words. wc -w file.txt -c Count only the number of characters. wc -c file.txt -m Count the number of characters, including newline characters. wc -m file.txt -L Print the length of the longest line. wc -L file.txt -help or --help Display the help message with usage instructions and available options. wc --help
  • 18. Command: rm Description: Remove files and directories. Useful Flags/Switches/Options: Flag Description Example -r Recursively remove directories and their contents. rm -r directory/ -f Forcefully remove files without prompting for confirmation. rm -f file.txt -i Interactively prompt for confirmation before removing each file. rm -i file.txt -v Verbose mode, display detailed information about the files. rm -v file.txt -d Remove empty directories. rm -d empty_directory/ -rf A combination of the -r and -f options, useful for forcefully removing directories and their contents without prompting for confirmation. rm -rf directory/
  • 19. Command: `cp` (short for "copy") Description: The `cp` command is used to copy files and directories in Linux/Unix systems. Useful Flags/Switches/Options: Flag Description Example -r or -R Recursively copy directories and their contents. cp -r directory1 directory2 -i Prompt for confirmation before overwriting existing files. cp -i file1 file2 -u Copy only when the source file is newer than the destination file. cp -u file1 file2 -p Preserve file attributes (permissions, timestamps, etc.) during the copy. cp -p file1 file2
  • 20. Command: mv (Move/Rename) Description: The `mv` command is used to move or rename files and directories. Useful Flags/Switches/Options: Flag Description Example -i Prompt for confirmation before overwriting an existing file. mv -i file.txt new_location/ -u Update (move) only when the source is newer than the destination. mv -u source.txt destination/ -v Verbose mode, display detailed information about each file moved. mv -v file1.txt file2.txt -n No-clobber, do not overwrite an existing file. mv -n file.txt new_location/ -b Create a backup of an existing file before moving it. mv -b file.txt new_location/ -t Specify the target directory for the moved file(s). mv -t destination/ file1.txt file2.txt --help Display the help manual for the mv command. mv --help
  • 21. Command: `du` (Disk Usage) Description: The `du` command is used to estimate and display the disk space usage of files and directories. Useful flags/switches/options: Flag Description Example -h Print sizes in human-readable format (e.g., 1K, 234M, 2G) du -h directory -s Display the total sum of sizes for directories du -s directory -a Include individual files in the output, in addition to directories du -a directory -c Show a grand total of the disk usage at the end of the output du -c directory1 directory2 -x Skip directories on different file systems du -x directory --exclude Exclude specific directories or files from disk usage calculation du --exclude=directory1 --exclude=file.txt --max-depth Set the maximum depth of the directory tree to be displayed du --max-depth=3 directory
  • 22. Command: df (Disk Free) Description: Display disk space usage information. Useful Flags/Switches/Options: Flag Description Example -h or --human- readable Display sizes in human-readable format (e.g., "10G" for gigabytes). df -h -i or --inodes Display inode information (number of used and available inodes). df -i -x or --exclude-type Exclude specific file system types from the output. df -x nfs -t or --type Limit the output to specific file system types. df -t ext4
  • 23. Command: top/topas Description: The `top` or `topas` command is used to monitor system activity, providing real-time information about CPU usage, memory usage, running processes, and other system statistics. Useful Flags/Switches/Options: Flag Description Example -d Specify the refresh rate or delay between updates (in seconds). top -d 5 (Updates every 5 seconds) -b Run top in batch mode, printing output once and exiting. top -b (Run top in batch mode) -p Monitor specific process IDs (PIDs) instead of all processes. top -p 1234 (Monitor process with PID 1234) -n Set the number of iterations before top exits. top -n 10 (Exit after 10 iterations) -s Sort processes based on a specific field (e.g., %CPU, %MEM, COMMAND). top -s %CPU (Sort by CPU usage) -R Reverse the default sorting order. top -s %MEM -R (Sort by memory usage in descending order)
  • 24. Command: free Description: Displays memory usage in kilobytes. Useful Flags/Switches/Options: Flag Description Example -h Provides human-readable output with sizes in powers of 1024 (e.g., KB, MB, GB). free -h -b Displays memory sizes in bytes. free -b -k Displays memory sizes in kilobytes (default option). free -k -m Displays memory sizes in megabytes. free -m -g Displays memory sizes in gigabytes. free -g
  • 25. Command: sh Description: The `sh` command is a command-line interpreter for executing shell scripts. Useful flags/switches/options: Flag Description Example -e Exit immediately if any command exits with a non-zero status sh -e script.sh -x Print each command before executing it (enables script debugging) sh -x script.sh -n Check syntax errors in the script without executing it sh -n script.sh -r Prevent the shell from reading the user's initialization files sh -r script.sh
  • 26. Command: ./ (dot slash) Description: The `./` command allows you to run a script or program located in the current directory. Example: Assuming you have a script named "script.sh" in the current directory, you can execute it using `./script.sh`. Useful Flags/Switches/Options: - There are no specific flags or options for `./` itself, as it is simply a way to execute a file in the current directory. Note: Remember to make the script executable by setting the appropriate permissions using `chmod +x script.sh` before executing it with `./`.
  • 27. Command: nohup Description: `nohup` runs a command that persists even after the user logs out. Useful Flags/Switches/Options: Flag Description Example -n Redirects the output to a specified file instead of the default nohup.out file. nohup command > output.txt -p Saves the process ID (PID) of the command to a specified file. nohup -p pid.txt command -h Displays the usage information and exits. nohup -h -v Prints the version information and exits. nohup -v -c Specifies a shell command to be executed. nohup -c "echo Hello, World!"
  • 28. Command: ps Description: The `ps` command is used to display information about active processes running on the system. Useful Flags/Switches/Options: Flag Description Example -e Show information about all processes. ps -e -f Full format listing, providing detailed information about each process. ps -f -u <username> Display processes owned by a specific user. ps -u john -p <pid> Show information about a specific process identified by its process ID (PID). ps -p 1234 -o <format> Specify a custom output format for the process listing. ps -o pid,ppid,user,cmd -aux Display a comprehensive list of all processes with detailed information, including those of other users. ps -aux -L Show threads associated with each process. ps -L -C <name> Display processes with a specific command name. ps -C nginx --forest Show processes in a tree-like format, indicating their parent-child relationships. ps --forest
  • 29. Command: kill Description: The kill command is used to terminate processes by sending signals to them. It allows you to stop running processes manually. Useful flags/switches/options: Flag Description Example -l or --list List all available signal names. kill -l <signal> Specify the signal to send to the process. kill -SIGTERM <PID> Commonly used signals include: SIGTERM (15): Terminate the process gracefully. SIGKILL (9): Forcefully terminate the process. SIGQUIT (3): Quit the process and generate a core dump/thread dump. <PID> Specify the process ID (PID) of the process to be terminated. kill 1234 -s <signal> Specify the signal to send using a numerical value. kill -s 15 1234 -a or --all Send the specified signal to all processes except kill itself. kill -SIGTERM -a -3 or SIGQUIT Same as -s SIGQUIT or kill -SIGQUIT. Sends SIGQUIT to process.
  • 30. Command: ifconfig Description: Display and configure network interface parameters. Useful Flags/Switches/Options: Flag Description Example ifconfig Display the configuration of all active network interfaces. ifconfig ifconfig <interface> Display the configuration of a specific network interface. ifconfig eth0 ifconfig <interface> up Activate a network interface. ifconfig eth0 up ifconfig <interface> down Deactivate a network interface. ifconfig eth0 down ifconfig <interface> <IP_Address> Assign a specific IP address to a network interface. ifconfig eth0 192.168.0.10 ifconfig -a Display all network interfaces, including inactive ones. ifconfig -a ifconfig -s Display a brief summary of network interfaces. ifconfig -s ifconfig -v Display verbose output with detailed information. ifconfig -v
  • 31. Command: telnet Description: Telnet is a network protocol used to establish a connection to a remote computer or server over a TCP/IP network. It allows you to interact with the remote system through a command-line interface. Useful flags/switches/options: Flag Description Example -l username Specify a username for login. telnet -l myusername remote-server.com -p port Specify a specific port to connect to (default is port 23 for Telnet). telnet remote-server.com 8080 -a Attempt automatic login. telnet -a remote-server.com -e escapechar Set the escape character used to enter telnet commands during an active session. telnet -e ^] remote-server.com
  • 32. Command: netstat Description: The `netstat` command is used to display network-related information in various forms. Useful Flags/Switches/Options: Flag Description Example -a or --all Display all active connections, including listening ports. netstat -a -t or --tcp Display TCP connections only. netstat -t -u or --udp Display UDP connections only. netstat -u -n or --numeric Show numeric IP addresses and port numbers instead of resolving them to hostnames. netstat -n -p or --programs Show the process ID (PID) and name associated with each connection. netstat -p -l or --listening Display only listening (server) sockets. netstat -l -r or --route Display the kernel's IP routing table. netstat -r -s or --statistics Display network statistics and summary information. netstat -s -c or --continuous Continuously display updated information. netstat -c -h or --help Show the help message with command usage and available options. netstat -h
  • 33. Command: ping Description: The `ping` command sends ICMP Echo Request packets to a specified destination IP address or hostname and waits for ICMP Echo Reply packets, allowing you to check network connectivity and measure round-trip time. Useful Flags/Switches/Options: Examples: 1. `ping google.com`: Send ICMP Echo Request packets to google.com to test network connectivity. Press Ctrl+C to stop. 2. `ping -c 10 -i 2 example.com`: Send 10 ICMP Echo Request packets to example.com with a 2-second interval between each packet. Flag Description Example -c count Specify the number of ICMP Echo Request packets to send. ping -c 5 google.com -i interval Set the interval (in seconds) between successive packets. ping -i 1 example.com -W timeout Set the timeout (in seconds) for each reply. ping -W 2 example.com -v Verbose output, showing detailed information about each packet. ping -v example.com
  • 34. Command: tar Description: The `tar` command is used for archiving files and directories into a single file. It is often used for creating backups or distributing multiple files as a single package. Examples: • Create a tar archive: tar -cf archive.tar file1.txt file2.txt directory/ • Extract files from a tar archive: tar -xf archive.tar • Create a compressed tar archive using gzip: tar -czf archive.tar.gz directory/ • Create a compressed tar archive using bzip2: tar -cjf archive.tar.bz2 directory/ • List the contents of a tar archive: tar -tf archive.tar • Extract files from a tar archive to a specific directory: tar -xf archive.tar -C /path/to/target • Update an existing tar archive with newer files: tar -rf archive.tar newfile.txt Useful Flags/Switches/Options : Option Description Option Description -c Create a new archive. -z Compress the archive using gzip. -x Extract files from an archive. -j Compress the archive using bzip2. -f Specify the archive file name. -t List the contents of an archive without extracting. -v Verbose mode to display detailed output. -C Specify the target directory for extraction. -u Update the archive with newer files only. -p Preserve file permissions, ownership, and timestamps. -r Append files to an existing archive.
  • 35. Command: gzip Description: `gzip` is a command-line tool used for file compression in Linux and Unix-based systems. It reduces the size of files, making them easier to store and transfer. Useful Flags/Switches/Options: Flag Description Example -c Write the compressed output to standard output without modifying the original file. gzip -c file.txt > compressed_file.gz -d or --decompress Decompress a compressed file. gzip -d compressed_file.gz -r or --recursive Compress files in a directory and its subdirectories recursively. gzip -r directory -k or --keep Keep the original file after compression, preserving both the compressed and uncompressed versions. gzip -k file.txt -t or --test Test the integrity of a compressed file without decompressing it. gzip -t compressed_file.gz -v or --verbose Display verbose output, showing the compression ratio and the file name. gzip -v file.txt
  • 36. Command: gunzip Description: The `gunzip` command is used to decompress files compressed with the gzip compression algorithm. Useful Flags/Switches/Options: Flag Description Example gunzip Decompresses files compressed with gzip. -c Writes the decompressed output to standard output without modifying the original file. gunzip -c file.gz -k Keeps the original compressed file and creates a new decompressed file. gunzip -k file.gz -f Forces the decompression even if the target file already exists. gunzip -f file.gz -r Recursively decompresses files in a directory and its subdirectories. gunzip -r directory/ -l Lists information about the compressed files without decompressing them. gunzip -l file.gz -v Displays verbose output with the decompression progress and details. gunzip -v file.gz
  • 37. Command: zcat Description: `zcat` allows you to view the contents of compressed files without actually decompressing them permanently. It is typically used with files compressed using the gzip compression algorithm. Useful Flags/Switches/Options: - `-f`: Forces `zcat` to decompress files even if they do not have the `.gz` extension. Example: `zcat -f file.txt` - Examples: 1. `zcat file.txt.gz`: Display the contents of a compressed file `file.txt.gz`. 2. `zcat -f file.txt`: Decompress and display the contents of a file even if it does not have the `.gz` extension. 3. `zcat *.gz`: Display the contents of multiple compressed files in the current directory. 4. `zcat -f *.txt`: Decompress and display the contents of files with or without the `.gz` extension.
  • 38. Command: sftp Description: The `sftp` command is used for secure file transfer between a local host and a remote host over SSH (Secure Shell) protocol. It provides an interactive interface for transferring files and performing various file operations on the remote server. Useful Flags/Switches/Options: Flag Description Example -P port Specify a custom SSH port for the connection. sftp -P 2222 user@host -b batchfile Execute a batch file containing a sequence of sftp commands. sftp -b batchfile.txt user@host -r Recursively transfer directories and their contents. sftp -r user@host:/remote/dir /local/dir -i identity_file Specify a private key file for authentication. sftp -i private_key.pem user@host -v Verbose mode, displays detailed information about the file transfer process. sftp -v user@host -q Quiet mode, suppresses progress and informational messages. sftp -q user@host get Download a file from the remote server to the local machine. get remote_file.txt put Upload a file from the local machine to the remote server. put local_file.txt ls List files and directories on the remote server. ls cd Change the remote server's working directory. cd /path/to/directory
  • 39. Command: ssh (Secure Shell) Description: ssh is used to establish a secure encrypted connection to a remote server or device over a network. It provides a secure way to access and manage remote systems. Useful flags/switches/options: Flag Description Example -p Specifies the port number to connect to the remote server. ssh -p 2222 username@remote_server -i Specifies the identity file (private key) for public key authentication. ssh -i /path/to/private_key username@remote_server -l Specifies the username to use for the remote connection. ssh -l username remote_server -X Enables X11 forwarding, allowing the remote server to display graphical applications on the local machine. ssh -X username@remote_server -L Sets up local port forwarding, allowing connections to a local port to be forwarded to a remote server. ssh -L 8080:localhost:80 username@remote_server -R Sets up remote port forwarding, allowing connections to a remote port to be forwarded to a local server. ssh -R 2222:localhost:22 username@remote_server -C Enables compression for the SSH connection, reducing bandwidth usage. ssh -C username@remote_server -N Requests an SSH connection without executing any remote commands. ssh -N -L 8080:localhost:80 username@remote_server
  • 40. Command: find Description: Search for files and directories recursively based on specified criteria. Useful Flags/Switches/Options: Flag Description Example -name Search for files/directories with a specific name or pattern find /path/to/search -name "*.txt" -type Filter by file type find /path/to/search -type f -size Search based on file size find /path/to/search -size +1M -mtime Search based on file modification time find /path/to/search -mtime +7 -exec Execute a command on each found file or directory find /path/to/search -name "*.txt" - exec ls -l {} ; -delete Delete files or directories that match the search criteria find /path/to/search -name "*.txt" - delete
  • 41. Command: locate Description: `locate` quickly finds files by name using a prebuilt database. Useful Flags/Options: Flag Description Example -i Perform a case-insensitive search. locate -i filename -r Use regular expressions for pattern matching. locate -r '^file.*.txt$' -l Limit the number of results displayed. locate -l 10 filename -c Count the number of matching files. locate -c filename -n Limit the number of database matches scanned. locate -n 100 filename -b Match only the basename of the file. locate -b filename -e Treat the search pattern as an exact match. locate -e "exact_filename" -q Quiet mode, suppress error messages. locate -q filename
  • 42. Command: uname Description: Print system information. Useful Flags/Options: Flag Description Example -a or --all Print all available information. uname -a -s or --kernel-name Print the kernel name. uname -s -n or --nodename Print the network node hostname. uname -n -r or --kernel-release Print the kernel release. uname -r -v or --kernel-version Print the kernel version. uname -v -m or --machine Print the machine hardware name. uname -m -p or --processor Print the processor type or "unknown". uname -p -i or --hardware-platform Print the hardware platform. uname -i -o or --operating-system Print the operating system. uname -o