Here is a list of essential SSH commands commonly used when working on a Linux server.
ls: List files/directoriesls -al: List all files with details, including hidden onescd /path: Change to a specific directorycd ~: Go to home directorycd -: Go to the previous directorycd ..: Go up one directorycat filename.txt: Print file contentstail -f /var/log/messages: Continuously view log updatesmore /etc/userdomains: View file one screen at a timetouch filename: Create an empty filerm filename: Delete a filerm -rf folder/: Delete folder and all contents (⚠️ dangerous!)cp source target: Copy filesln -s original linkname: Create a symbolic linkpico file: Simple editorvi file: Advanced editor (steep learning curve)grep pattern file: Find text pattern in a filegrep -v pattern file: Exclude lines matching the patternw: Who is logged in and from wherelast: Recent loginsnetstat -an: Active network connectionsTop: Live System Resource Monitorps aux: List all running processesps aux --forest: Hierarchical process listkill -9 PID: Force terminate a processfile *: Identify file typesdu -sh: Total disk usage of the current directorydu -sh *: Disk usage by each itemwc -l file: Count lines in a filecommand1 | command2: Pipe the output of one into anothercommand > file: Redirect output to file (overwrite)command >> file: Append output to filecommand < file: Use file as inputgrep User /usr/local/apache/conf/httpd.conf | more last -a > /root/lastlogins.tmp tail -10000 /var/log/exim_mainlog | grep domain.com | more netstat -an | grep :80 | wc -l mysqladmin processlist | wc -l mysqldump -u username -ppassword dbname > file.sql tar -zcvf archive.tar.gz directory/ tar -zxvf archive.tar.gz mysql -uusername -ppassword database_name
⚠️ Note: Always double-check before running commands like rm -rf or kill -9 to avoid accidental damage.
Add Comment