My Linux cheatsheet
09 Nov
Tagged bash, centos, cheatsheet, code, FLOSS, shell
The second line extracts all /etc files from the rpm to ./etc
On CentOS 4:
On CentOS 5:
Note: There will be other dependencies but Yum will resolve them automatically.
Substitute eth0 with the device you wish to identify.
And for up2date
I have a text file with some of my favorite Bash commands and I thought I'd share them. Some are specific to CentOS/RHEL/Fedora but most are simple and useful. Feel free to comment if you can improve on any of them. Cheers.
Show all installed packages and order by size
rpm -qa --queryformat "%12{SIZE} %{NAME}\n" | awk {'print $1" "$2'} | sort -n +0
Show all installed packages and order by date
rpm -qa --queryformat '%{installtime} %{name} %{version}-%{release} %{installtime:date}\n' | sort -nr +1 | sed -e 's/^[^ ]* //'
Display RPM files then extract specific directories or files
rpm -qlp file.rpm
rpm2cpio file.rpm | cpio -ivd ./etc/*
rpm2cpio file.rpm | cpio -ivd ./etc/*
Install packages required for remote X (SSH X forwarding)
I use this one mostly for running Wireshark on Cygwin so I've also included wireshark.On CentOS 4:
yum install fonts-xorg-base xorg-x11-xauth wireshark-gnome
yum install xorg-x11-fonts-Type1 xorg-x11-xauth wireshark-gnome
Identify Eth device physically by blinking its LED
ethtool -p eth0 5
Watch a threads of a process
watch ps um -C processname
Check syntax of all PHP files in a directory
for i in *.php; do php -l $i; done
Check for updated packages and email the results
I set this up as a weekly cron job.yum --exclude=none check-update | /bin/mail <your email address> -s "hostname.example.com yum available packages"
up2date --nox -l | /bin/mail <your email address> -s "hostname.example.com up2date available packages"
