Update: January 5, 2020

Bash is an interactive command-line interpreter or shell. I would like to share the common usage of my shell commands and what they are. I have created this list for time-saving purposes. Because without GUI, all transaction moves faster without mouse usage.

This article is a guide for my next article — Bash Script Guide for iOS Developers, stay tuned for that!


$ history used to sort the commands used for the previous.


$ nslookup allows you to query the IP address directed by the DNS server


$ ifconfig shows the machine’s IP configuration.


Lists the folder and file names in the current working directory.

$ ls -a lists all files including hidden files

$ ls -A lists all files, including hidden files, except a top directory

$ ls -F add an indicator (one of */=>@|) to entries

$ ls -S sort by file size

$ ls -al provides a list of all the files in the same directory

$ ls -l Use a long listing format

$ ls -nl Use a long listing format with user ID

$ ls -c list contents by columns


It is the interface used to view the system’s reference manuals.man ls also displays all the options available for running the command.

$ man - Print a help message and exit

$ man -V --version Display version information and exit

$ man -C Use the configuration file rather than the default of ~/.manpath.

$ man -d Print debugging information.


Returns a list of the environment variables for the current user.

$ env


To change the permissions of files or directories.

$ chmod 777 anyone can read, write and execute chmod 777 my_file

$ chmod 755for files that should be readable and executable by others, but only changeable by the issuing user

$ chmod 700only the user can do anything to the file


Changes ownership of files and directories.

$ chown --help && chown --version


It stores a list of directories separated by a colon.

$ echo $PATH


Searches files for lines that match a pattern and returns the results.

$ grep "keyword" file.txsearches for the given string in a single file

$ grep -i "keyword" file.txenables the command to be case insensitive

$ grep -R "keyword" file.txsearches all files in a directory and outputs filenames and lines containing matched results


Extracts just a list of specific things.

$ awk {keyword} file.tx


Opens current folder in finder.

$ open .


Changes the group of the file and directory.

$ chgrp groupname file.txt


The command prints the name of the working directory.

$ pwd


Changes the current working directory.

$ cd / goes to the root directory

$ cd .. goes to a parent directory

$ cd goes to the user's home directory when executed without the parameter

$ cd ~root goes to the user's home directory when the user name is given after the ‘~’


Displays the path of the home directory.

$ echo $HOME


Command line text editor and only accepts keyboard input.

$ nano myscript.sh


Searches for files and directories.

$ find directory -name filename: searches the file by name

$ find directory -cnewer file: The file was last changed more recently than the file was modified

$ find directory -amin n: The file was last accessed n minutes ago

$ find directory -cmin n : The file was last changed n minutes ago

$ find directory -atime n: The file was last accessed more n days ago

$ find directory -mtime n: File’s data was last modified n days ago

$ find directory -ctime n: The file was last changed more than n days ago

$ find directory -print: Displays the pathname of the files found by using the rest of the criteria

$ find directory -exec: Executes commands on the resulting search results


Creates directories with this command.

$ mkdir folder: This command would create the subfolders


Moves a file or directory as another file and directory.

  • mv -i source: Prompt before overwriting an existing file
  • mv -f source: Always overwrite existing files without prompting
  • mv -n source: Never overwrite any existing file
  • mv -v source: Print source and destination files


Removes objects.

rm -f file: Does not ask questions during deletion, does not provide information for a non-existent file

rm -i file: Prompt before deleting files

rm -r directory: Deletes the contents of directories and subdirectories consecutively

rm -v file: Gives more detailed information about the remove process


Removes directory, this command only works if the folders are empty.

rmdir -p directoryname


Creates or opens a file and saves it without any change to the file contents.

$ touch -a file: Updates file access time

$ touch -c file: If the file does not exist, it creates the file

$ touch -m file: Changes the file modification time

$ touch -t file: Changes the file access or replacement time as specified


Shows the contents of the files.

$ cat -n file: Prints the contents of the file on the screen by giving a number to all lines


Prints newline, word, and byte counts for each FILE, and a total if more than one FILE is specified

$ wc -l file: Returns the number of rows

$ wc -m file: Returns the number of characters

$ wc -w file: Counts the number of words


Displays the first lines of the file.

$ head file: Shows the first couple lines


Displays the last couple of lines of the file.

$ tail file: Shows you the last couple of lines


The contents of the file are used to display the page page.

$ more file


Allows backward movement in the file as well as forward movement.

$ less file


Adds a line number per line.

$ nl file

That’s it. 😃😃😃 Thanks for reading. I hope all these tools will help you to improve your productivity.

If you want to follow me on social media, here are some links: github, twitter, linkedin

You can check my previous articles here.

Health Research Program’s iOS Developer, currently lives in Washington, D.C http://www.about.me/durul

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store