If you’re new to Linux: here’s a minimal workflow to SSH into a server (e.g., EC2), understand where you are, read files, and check host health safely.
/var/log.ls lists files.Right after SSH, ask:
whoami # shows the current user (e.g., ubuntu, ec2-user)
hostname # server hostname (helps you confirm which machine you are on)
pwd # "print working directory": current directory
uname -a # system info (kernel, architecture) for quick context
uptime # how long it has been running + load average (high load can mean trouble)
date # current date/time (useful when correlating logs)
Think of this as a file explorer, but using commands.
pwd # where am I (current location)
ls # list files/folders here
ls -lah # detailed listing: permissions, owner, size, date (very common on servers)
cd /var/log # cd = change directory: move to /var/log (typical log folder)
cd .. # go one level up (from /var/log -> /var)
cd ~ # go to your home directory
cd # with no arguments = also goes to home
clear # clears the screen (visual only)
pwd
ls -lah
In DevOps you often read logs and configs. Learn to read safely first.
cat file.txt # prints the whole file (best for small files)
less app.log # interactive viewer (best for large logs)
# inside less:
# - press 'q' to quit
# - use arrows / PageUp / PageDown to move
# - type /ERROR then Enter to search for "ERROR"
head -n 50 app.log # first 50 lines
tail -n 50 app.log # last 50 lines
tail -f app.log # follow logs live (updates as new lines appear)
# Ctrl + C to stop
This is where beginners often break things. Let’s do it carefully.
mkdir folder # create a folder
mkdir -p a/b/c # create nested folders even if parents don't exist (-p)
touch file.txt # create an empty file (or update timestamp if it exists)
cp source.txt copy.txt # copy a file
cp -r folder1 folder2 # copy a whole folder (-r = recursive)
mv old.txt new.txt # rename a file
mv file.txt /tmp/ # move a file to /tmp (temporary folder)
rm file.txt # delete a file (no recycle bin)
rm -r folder/ # delete a folder and contents (careful)
rm -rf folder/ # force delete without prompts (VERY careful)
pwd
ls -lah
When you don’t know where a file is, or you need to search logs:
find . -name "file*.log" # search from current directory (.)
# matches names like file123.log
grep -R "ERROR" . # search the word ERROR in all files recursively
grep -n "ERROR" app.log # search in one file and show line numbers (-n)
These tell you if the server is healthy or near failure.
df -h # disk space (100% disk can break services)
free -h # memory (low memory can cause swapping and slowness)
ps aux | head # processes (head shows only the first few lines)
top # real-time monitoring (CPU/memory/processes)
# press 'q' to quit
ip a # network interfaces + IP addresses
ss -tulpen # listening ports + owning processes (great for troubleshooting)
uptime, top, free -h, df -h.tail -f and verify ports with ss -tulpen.find or grep to locate it quickly.less and tail -f are essential for reading logs safely.pwd + ls -lah. On servers, there is no recycle bin.df), memory (free), processes (top), network (ip/ss).