KNOWLEDGEBASE · LINUX
Basic SSH Commands
Last updated 2025-06-08
🖥️ Basic SSH Commands
Here is a list of essential SSH commands commonly used when working on a Linux server.
📂 File & Directory Commands
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 link
📝 Text Editors
pico file: Simple editorvi file: Advanced editor (steep learning curve)
🔍 Searching & Monitoring
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 process
💾 Disk & File Info
file *: Identify file typesdu -sh: Total disk usage of the current directorydu -sh *: Disk usage by each itemwc -l file: Count lines in a file
🛠️ Combining Commands
command1 | command2: Pipe the output of one into anothercommand > file: Redirect output to file (overwrite)command >> file: Append output to filecommand < file: Use file as input
Examples:
grep 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.
Tell us what has to stay up.
A short conversation with an engineer. No quote-bot, no callback queue. We'll tell you honestly if we're not the right fit.