Tips: Handy Linux commands
This is a post that will no doubt be updated as and when we find new useful commands. If you have any suggestions just let us know in the comments
# List all users with UIDs less /etc/passwd # Check partition sizes df -h # Check directory size du -s -h /var/log/ # Check every directory and file sizes under a dir du -s -h /var/log/* # Check individual size size du -s -h /var/log/lastlog # List processes and their associated ports sudo lsof -i # Use ls to obtain only directories ls -d */ # Show number of files in a directory ls | wc -l <em>OR</em> ls | wc -l # Make a symlink ln -s <em>targetdir linkname</em>
# List installed packages on debian based OS for php in this example dpkg --get-selections | grep php
# Find out which yum packages provide a certain file or library yum provides \*/
# Backup a database mysqldump -u root -p dbname > outputfile.sql
# Create individual tar.gz archives for multiple folders in a directory. Create the following bash script and chmod +x it. for d in *; do [[ -d "$&;d" ]] || continue tar cvzf "$&;d.tar.gz" "$&;d" done
Note: These commands must run from within the VirtualBox program directory eg. C:\Program Files\Oracle\VirtualBox\
# To increase a virtual drive's size VBoxManage modifyhd wim.vdi --resize 20000
Like this Article? Share it!
About the Author
Andy has been in IT support in the academic industry for over 7 years now, with an in-depth knowledge of both Windows and Unix based systems.