- Home
- Learn Linux
- Learn Electronics
- Raspberry Pi
- Programming
- Projects
- LPI certification
- News & Reviews
These are some example commands with typical command options.
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 \;
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
Search for package
apt-cache search <searchterm>
or
apt search <searchterm>
Install package from repository
sudo apt-get install <packagename>
or
apt install <packagename>
Install package from localfile
sudo dpkg --install <packagename.deb>
Update package listsfrom repositories
sudo apt update
Upgrade installed packages to latest version
sudo apt upgrade
Basic script to perform something against a number of files
for filename in * ; do echo > $filename; done
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