Vannkorn

Full Stack Web Developer

Close

Some useful Linux commands I once in a blue moon use

It's annoying when you need to do certain things on Linux environments and you forgot the command to tell the computer what to do.

Ads: Register now via this link to receive $300 credit from Vultr

It’s annoying when you need to do certain things on Linux environments and you forgot the command to tell the computer what to do.

This happens to me all the time and so does everyone on the planet, not limited to tech people, I believe.

Without further ado, here are the Linux commands I find useful and worth to note down:

Check storage size:
df -h
Check a directory size:
du -h /path/to/directory
Delete file content:
truncate -s 0 [file-name]
List down files whose size are more than 100MB:
find / -size +100M -ls
List down files between 100MB and 1GB:
find / -size +100M -size -1024M -ls
List all system users:
less /etc/passwd
Change ownership of the specific user recursively down the folders:
chown -R [user]:[group] *
Zip the entire directory
zip -r filename.zip *
Zip multiple directories into a single zip file
zip -r filename.zip folder-1 folder-2 folder-3
Extract the zip file to the current directory
unzip filename.zip
Checking if swapfile is runing
free -h
Stop swapfile from running before removing it
sudo swapoff /path/to/swapfile/to/be/deleted
To remove string/texts on the current line, first place the cursor at the start of the line and hit Ctrl + k

Leave a Reply

Your email address will not be published. Required fields are marked *