Linux: Useful commands

Get serial number
sudo dmidecode -t system | grep Serial

Count number of sub-directories in current directory
ls -l | grep -c ^d

Copy multiple directories from within another directory
cp -a /path/from /path/to

Make script file (.sh) executable
chmod +x

Copy a directory to a new directory:
cp directory1 /opt/directory2 -R

NB The “-R” is required when copying a directory rather that just a file.

List only NFS mounts:
mount -l -t nfs

Is my Linux x86 or x64
Type “arch”. If it returns “i686” or “i386” then it’s 32-bit, if it returns “x86_64” it is 64-bit

Unzip tar
tar -xvzf file_name.tar.gz

Check if a server (Windows included) is listing an NFS share for export
showmount -e

Check version of Debian server
cat /etc/debian_version


Check codename of Debian server i.e. Wheezy, Jessie etc
lsb_release -a


see here for more details of codename release details.

Disclaimer: provided “AS IS” with no warranties and confer no rights