Linux Logo

10 Linux Commands Developers should Know

Linux commands should be known by every developer. Even though, development may happen in one’s Windows or IOS, but when placed in the server, the server’s OS is most probably a Linux. This means that developers will have to navigate through it using Linux. So here is a list of 10 Linux commands that one should master.

Directory Management and Traversing

  1. ls
    Lists the content of the current directory. If a string (directory) is passed to it, it will list the content of that directory. Important switches (the ones that are preceded by -) are – lists all including filenames preceded with . (dot); – lists in long format – showing other information.
    >> ls #shows files on the current directory
    >> ls /var/www #shows files from directory: /var/www
    >> ls -a #shows all files including hidden files or files preceded by . (dot)
    >> ls -al #shows all files and their information
  2. cd
    Traverse to a different directory. If a .. is passed cd .. # double dot , will traverse to the parent directory. Passing a string as an argument will let it move towards that directory.  When the first character of the directory is / (slash), it will be relative to the root directory.
  3. pwd
    This will print the full pathname of the current working directory.
  4. mkdir
    This will create a directory. A very important switch is the – this will create parent directories if they don’t currently exist.
  5. Linux Commands for File Management

  6. rm
    This Linux command will remove files. An important switch for rm is -R (could also be -r or –recursive). This will recursively remove all files and directories. Another switch is f which will delete files without prompting you even when the file(s) are write-protected.
  7. cp
    Copy files or directories. This takes the format: cp [options] source destination. The most important option (switch) is: r (-R or –recursively) – which will copy files and directories.
  8. mv
    This will move a file or copy a file to a different filename. The format is mv [options/switches] source destination where the usual switches are f, i or r.
  9. Linux Commands for File/Directory Ownership and Permissions

  10. chmod
    This will change permissions on files or directories. The format is: chmod [options/switches] permissions filename_or_directoryExamples:
    >> chmod u=rwx,g=rx,o=r myfile #user can read,write and execute; group can read and execute; others can only read
    >> chmod 754 myfile #the same command above but in octal option
    >> chmod -R 755 myfiles #recursively go through all files in myfiles folder and change permission to 755
  11. chown
    This command will change ownership to a file or directory. The format is: chown [options] [user[:group]] filenam_or_directory. Only root can change ownership of a file. Even the owner cannot transfer ownership, unless the owner is root, or he is a sudoer and he prepends sudo to run the command. Examples:
    >> sudo chown user:ongroup myfile.txt #change ownership of myfile.txt to user and of group ongroup
    >> sudo chown -R myuser:mygroup otherfiles #recursively go through all files in otherfiles directory
  12. cat
    The linux command cat has three related functions with regard to text files: displaying them, combining copies of them and creating new ones. Examples:
    >> cat thefile #will output the content of thefile
    >> cat file1 > file2 #will copy the content of file1 to file2
    >> cat file1 file2 > file3 #will concatenate the content of file1 and file2 to file3

    These are only the essentials and I’m still planning to expand this with more complicated ones. Here are other Linux commands you can also master: ln – to create symbolic links between files; find – locate files; df – show disk usage; diff – compare two files; and grep – to look for text based on a regular expression patterns on files.

Please follow and like us: