Essential Linux Commands
Essential Linux Commands
3. Process Operations:
● ps: Displays your currently active processes
● top: Displays all running processes
● kill pid: Kills the process with given pid
● pkill name: Kills the process with the given name
● bg: Resumes suspended jobs without bringing them to
foreground
● fg: Brings the most recent job to foreground
● fg n: Brings job n to the foreground
● renice +n [pid]: Change the priority of a running process.
● &>filename: Redirects both the stdout and the stderr to
the file
filename.
● 1>filename: Redirect the stdout to file filename.
● 2>filename: Redirect stderr to file filename.
4. File Permissions:
● chmod octal filename: Change the permissions of file to
octal,
which can be between 0 (no permissions) to 7 (full
permissions)
● chown ownername filename: Change file owner
● chgrp groupname filename: Change group owner
5. Networking:
● ping host: Ping a host and outputs results
● whois domain: Get whois information for domain
● dig domain: Get DNS information for domain
● netstat -pnltu: Display various network related
information such as network connections, routing tables,
interface statistics etc.
● ifconfig: Displays IP addresses of all network interfaces
● ssh user@host: Remote login into the host as user
● scp: Transfers files between hosts over ssh
● wget url: Download files from the web
● curl url: Sends a request to a URL and returns the
response
● traceroute domain: Prints the route that a packet takes
to reach the domain.
● mtr domain: mtr combines the functionality of the
traceroute and ping programs in a single network diagnostic
tool.
● ss: Another utility to investigate sockets. It's a more
modern alternative to netstat.
● nmap: Network exploration tool and security scanner.
8. Disk Usage:
● df: Shows disk usage
● du: Shows directory space usage
● free: Show memory and swap usage
● whereis app: Show possible locations of app
9. System Info:
● date: Show the current date and time
● cal: Show this month's calendar
● uptime: Show current uptime
● w: Display who is online
● whoami: Who you are logged in as
● uname -a: Show kernel information
● df -h: Disk usage in human readable format
10. Package Installations:
● sudo apt-get update: Updates package lists for upgrades
● sudo apt-get upgrade: Upgrades all upgradable packages
● sudo apt-get install pkgname: Install pkgname
● sudo apt-get remove pkgname: Removes pkgname
20. Others:
● yes > /dev/null &: Use this command to push a system to
its limit.
● :(){ :|:& };:: A fork bomb – handle with care. Do not run
this command on a production system.
Remember, you can always use the man command (e.g. man ls)
to get more information about each command.
Created by,
Ojas Jawale