Checklist : the main commands on UNIX

With Raspberry Pi, Some are discovering the world of Linux and more generally UNIX. Then this article is here to give you some tips/reminders for your manipulations under the console or SSH.


Find data

  • whereis : know where to find a file. Ex: whereis ls
  • which : What program will be executed by the shell when calling. It allows to find if a program is in several places. Ex: which ls
  • grep : search for a string in a file. Ex: grep <string> <file name>
  • egrep : as grep but allows searching with regular expressions.
  • find : searches files according to certain criteria. Can execute a command file find. Ex: find . -name “*.Java” -exec grep System {} \;

Find help

  • man : gives help on a program, a function. Install the package man

Manage files

  • MV : move a file. Ex: MV <file name> <new file name>
  • CAT : display the contents of a file. Ex: CAT <file name>
  • file : Displays the type of the file. Useful when it is not known how the file will be interpreted. Ex: file <file name>
  • CP : copy the file to another. Ex: CP <file name> <new file name>
  • touch : creating a file empty. Ex: touch <new file>

Manipulate directories

  • pwd : Displays the current directory
  • cd : move to a directory. Without parameters returns in the home directory of the logged in user
  • mkdir : creating a directory
  • rmdir : deleting a directory empty
  • RM-r : recursively delete a non-empty same directory. Attention 😉

Filter the information

  • more : display the contents of a file, page by page. Ex: more <file name>
  • less : as the command more with the possibility to return back. Ex: less <file name>
  • head : display the first lines of a file. Ex: head -50 <file name>
  • tail : display the last lines of a file. Ex: tail -50 <file name>
  • fate : sort the rows of a file based on the settings. Ex: fate <file name>
  • uniq : delete multiple lines in a file. Ex: uniq <file name>
  • column : organizes data into columns. Ex: Mount | column t
  • diff : will generate a report containing the differences between two files. Ex: diff <file A> <file B>
  • WC : count the number of lines/characters/words. Ex: WC <file name>

Manipulate the process

  • PS : Displays information about running processes. Select the type of information and filter settings.
  • Ptree : Show processes, their parent, the parameters used. Install the package zsh
  • kill : sending a signal to a process. The 15 request a clean shutdown of the process, the 9 It stops suddenly. Ex : kill -9 12345
  • top : Displays the information of the system and running processes. Cooling is automatic. A set of filters and sorting is configurable.

Information on the environment

  • Mount : mount a partition on the system. Without parameter, Displays the mounted partitions/drives.
  • DF : Displays the capacity and rate of occupancy of the partitions and mounted disks.
  • the : calculating the size of a directory including sub directories.
  • mpstat : Displays a set of statistics on a process. Install the sysstat package
  • iostat : Displays a set of statistics on the use of CPU and the system reads/writes. Install the sysstat package
  • nfsiostat : Displays a set of statistics on the use of the CPU and reads/writes of the NFS partitions. Install the sysstat package
  • fsck : perform a consistency of a partition or disk check (not mounted).

The list is far from complete (It is not the purpose of). If you see other important, feel free to share in the comments.

You may also like...