Third party cookies may be stored when visiting this site. Please see the cookie information.

Learn Linux Index

Getting started

The Linux shell and command line programs

System administration



Virtual machines

Web development


Other links

Linux misc commands quick reference guide

These are some example commands with typical command options.

Search Commands

Search for files - sort by filesize (add -r for reverse order)
find -type f | xargs ls -l | cut -c 33- | sort -n

Move files that are over 1 month old
find -atime +32 -exec mv {} /var/archive/logs \;

Installing / managing packages

RPM commands

List all installed packages
rpm -q -a

Upgrade packages
rpm -U -v *.rpm

Freshen packages This is the one you should use when applying the latest fixes
rpm -Fvh *.rpm

To find which rpm file (not installed) has the file libX
for i in `cat <dir to rpm files>`; do if rpm -qpl $i | grep libX >/dev/null; then echo $i; fi; done

Debian commands

Search for package
apt-cache search <searchterm>

Install package from repository
sudo apt-get install <packagename>

Install package from localfile
sudo dpkg --install <packagename.deb>

Update package listsfrom repositories
sudo apt-get update

Upgrade installed packages to latest version
sudo apt-get -u upgrade

Basic script functions

Basic script to perform something against a number of files
for filename in * ; do echo > $filename; done

Counting commands

To count number of none empty lines in a file
grep -v -e "^$" filename | wc -l

To count number of source code lines (perl)
find . -name "*.p?" | xargs grep -v -e "^$" - | wc -l

Previous Linux links reference guide
Linux links reference guide
Next Linux file access permissions reference
Linux file access permissions reference