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:

TMUX Essentials

I got introduced to tmux when I joined a seminar on Docker. While listening to the speaker going through the topics, and seeing how easily he went through folders in Linux and how he switched between panes – I immediately saw a solution to some problems I have. When I reached home, I got my hands dirty…

From the tmux github repo:

Tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more.

I keep several apps and services in the cloud. I connect to them via SSH using bash. Working on a terminal and running only one command each line is a headache for me. Much more, when the terminal times out you have to relogin again. Tmux is the solution to remedy these problems.

Currently, the only features from tmux that I’m using is opening several panes. Opening only two horizontal panes will do for me. I can move from one pane to the other. I can edit some codes on one, then move to the other pane to execute commands.

Several commands are available but here are the few that gets me through:

Starting/Ending a tmux server and/or session

>> tmux

Writing this on the Linux terminal will start the tmux server and an unnamed session. This gets me through when I’m on a hurry. But if you want to name it so you can get back to it  later, then you may

>> tmux new -s session_name

If you want to list the current sessions, you may write:

>> tmux list-sessions

The tmux server may be ended with the command:

>> tmux kill-server

Or to kill a session with name session_name you may:

>> tmux kill-session session_name

Tmux Panes and Pane Navigation

Some tmux commands are preceded by Ctrl+B. For example to create a horizontal pane you may write: Ctrl+B ” – which actually could be Ctrl+B Shift ‘.

Pane Commands:
Split current pane into 2 vertical panes: Ctrl+B %

Split current pane into 2 horizontal panes: Ctrl+B "

Show pane numbers: Ctrl+B Q

Shown pane number and go to that pane with pane_number (number designation): Ctrl+B Q pane_number

When traversing two panes, you may go from one pane to another with: Ctrl+B ;

Closing the current pane: Ctrl+B x (You may be prompted to answer y or n)


So there you go. These are the essentials I found so far.

Please follow and like us: