Basic Linux Commands
Published:
Below is a short collection of codes that I frequently use on our Ubuntu-based server.
Common commands
# Change directory
## Move to the upper-layer folder
cd ..
## Move to folder A in the current directory
cd A
# Check the content in the directory
ls
# Create a folder
mkdir foldername
# Move files or folders
mv source destination
# Copy files
cp source destination
# Remove files or folder
rm -r folder
# Zip files in terminal
zip -r newzipfile.zip folder
# Unzip to the current directory (where the zip file is in)
unzip zipfile.zip
Monitor the machine
Current status
# Open htop, a server monitor
htop
# Quit htop
q
# Another tool that keeps the list in terminal after quitting
top
# Quit top
q
Past activity
# In your local terminal
ssh -N -f -L 8080:localhost:8080 YourMachineAddress
# In your browser
localhost:8080/monitorix
Disk space
# For general and simple overview
df -h
# For file management: activate ncdu
ncdu # It might take a while to scan all files
# Delete files+ yes
d
# Quit ncdu
q