Command-Line Interface (CLI)
File and Directory Commands
ls
List files/folders
ls -a
List all files including hidden
pwd
Show current directory
cd <folder>
Change directory
cd /
Go to root directory
cd
or cd ~
Go to home directory
cd ..
Go up one directory
cd -
Go to previous directory
mkdir <folder>
Create directory
touch <file>
Create empty file
rm <file>
Delete file
rm -r <folder>
Remove folder and contents
rmdir <folder>
Remove empty folder
File Viewing and Editing
cat <file>
Show file contents
cat -n <file>
Show file with line numbers
cat > <file>
Create/overwrite file (input, Ctrl+D to end)
cat >> <file>
Append to file (Ctrl+D to end)
nano <file>
Simple text editor (Ctrl+O save, Ctrl+X exit)
vim <file>
Powerful editor (i insert, Esc, :wq save & exit)
Permissions and Ownership
ls -l <file>
Show file permissions and details
ls -@l <file>
Show permissions + extended attributes (macOS)
chmod u=rw,g=r,o=r <file>
Change permissions (owner/group/others)
chmod o+rw <file>
Add read/write for others
chown <user> <file>
Change file owner
chgrp <group> <file>
Change file group
sudo chown root <file>
Change owner to root
sudo chgrp root <file>
Change group to root
Process and System Commands
sudo
Run command as administrator
ps
/ ps aux
Show running processes
kill <pid>
Stop a process by process ID
top
/ htop
Interactive process viewer
bg
Send process to background
fg
Bring process to foreground
Package Managers
apt-get
Linux package manager
brew
macOS package manager
snap
Universal package manager
pip
Python package installer
Navigation Stack
pushd
Save current dir on stack + switch dir
popd
Return to previous directory on stack
Last updated