Linux pseudo files & cheat sheet

*A blog post that I’m actively collecting “Linux pseudo files info, cheat sheets and tips”

Tips & Tricks

  • How to force a command to return exit code 0 even the command exited non-zero?
  • How to install dependecies of .deb automatically which was failed to install previsouly?

Example Solution:

dpkg -i r-base-core_3.3.3-1trusty0_amd64.deb || : \
&& apt-get --yes --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -f install -y \
  • How traverse directories in shell script?

    cd command should not be used to traverse directories. Remember that each commands in shell script will spawn as individual process unlink programming language, entire script as single process i.e. The scope of cd command is only for child process not parent. By using pushd and popd we can achieve traversing directories.

Example Solution:

pushd Downloads
cat download.txt
pushd Downloads/movies


  • /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq - Real time speed of the CPU(ability to adjust their speed to help in saving on battery/power usage)

  • /proc Directory
    • /proc/cpuinfo | grep MHz - The absolute (max) CPU speed
    • /proc/sys/net/ipv4/* - Get more info under this directory from docs
    • /proc/net/tcp and /proc/net/tcp6 - Get complete info of variables for these files from
  • /proc/sysctl

  • Network related in Linux - Refer

Special Device Files

  • /dev/null - Discards all data written to it but reports that the write operation succeeded Read man pages

  • /dev/full - Returns the error code ENOSPC (meaning “No space left on device”) on writing Read man pages

  • /dev/random - Special file that serves as a blocking pseudorandom number generator. It allows access to environmental noise collected from device drivers and other sources.(Block until additional environmental noise is gathered)Read man

  • /dev/urandom - Without block Read man pages

  • /dev/zero - Provides as many null characters as are read from it Read More

  • udev - Linux dynamic device management Read man pages

    • udevadm - command to query the udev database and sysfs Read More


  • lscpu - Display CPU architecture information

  • cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 40 | head -n 1 - Generates 40 characters long random string

  • mtr - mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

  • lsblk - Lists block devices


  • /var/lock/ - Store lock files, which are simply files used to indicate that a certain resource (a database, a file, a device) is in use and should not be accessed by another process. Aptitude, for example, locks its database when a package manager is running.

  • /var/run - Used to store .pid files, which contain the process id of a running program. This is commonly used in services or other programs that need to make their process id’s available to other processes.

Written on April 14, 2018