Shelled! A Bourne-Again Introduction

Posted on Posted in Custom Programming, Stories

Bourne-Again Shell

Introduction to Bourne-again shell in programmingIn the past few years, Linux has started to become the operating system of choice in the enterprise server space, with distributions such as Red Hat Linux, Ubuntu, SUSE Linux Enterprise Server and Oracle Unbreakable Kernel making strong push to gain market share.

Given this trend, it is important for developers, programmers, and those in the software development industry to gain proficiency in working in the shell environment. While graphical user interface (GUI) exists for some of these Linux distributions, shell provides greater capabilities, flexibility and automation that cannot achieved using graphical desktop tools.

 

What is the “shell”?

The shell is command line interface (CLI) that reads commands typed into a console (all-text display mode) or a terminal window (all-text window) for the operating system to perform. Simply put, it acts as the interface between the user and the internal parts of the operating system (at the very core of which is the kernel).

On most Linux systems, graphical user interface (GUI) are merely front ends for shells; that is GUIs are built on top of a shell and uses this shell’s commands. Thus, although small in size, shells are powerful programs that is expected to perform various tasks.

There are a number of shells developed for UNIX-like systems, each with different commands, syntax, and functions. Some of these are sh (the Bourne shell, the original UNIX shell), ash (Almquist shell), csh (the C shell), ksh (Korn shell), and many others.

For Linux, the default shell is the bash, or the Bourne-again shell. It is also the default shell for OS X systems. While bash is a superset of sh and offer many powerful commands, it is also intuitive and flexible, and is probably the most suitable shell for beginners.

As such, bash is an important tool to learn and master for Linux administration, either for use in a desktop environment or in a server set up.

 

Frequently used commands

Below is a list of common and most used commands in bash.

  • sudo: run a command as another user, most often the root user
    • sudo !! → run last command with sudo
  • ls: list information about the files
    • ls -l → use a long listing of files
    • ls -al → use a long list of all (including hiding or entries starting with “.”) files
  • cd: change the directory
    • cd ~ → change to the current user’s home directory
  • pwd: print working directory
  • cp: copy file
    • cp –Rcopy single file
    • cp –Rrecursive/copy entire directory
  • mv: move file
    • mvmove single file
    • mv rename single file
  • watch: run any command at regular intervals
    • watch -d ls –l → watch the directory listing
  • chmod: change access permissions
    • chmod 777 change the file permission to allow read, write and execute access for all
  • chown: change user and/or group ownership of file
    • chown : change the file ownership to the specified user and user group
  • cat: display contents of a file
    • cat display the full contents of the text file
  • less: view file one screen at a time
    • less display the contents of the text file one screen at a time
  • df: check the available disk space
    • df –h → display the available disk space per mount point
  • du: check the disk usage
    • du –hs → display the disk usage on the current working directory
  • free: free RAM/available
    • free –m → display the current memory usage
      • you can also use top to the check overall health of the machine
  • shutdown
    • shutdown now → shutdown the system immediately
    • shutdown -r now → restart the system immediately
    • shutdown -r +10 → restart the system after 10 minutes

 

 

REFERENCES

http://linuxcommand.org/lc3_lts0010.php

http://www.thegeekstuff.com/2010/11/50-linux-commands/

http://www.linfo.org/shell.html

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.