Friday, March 17, 2017

A guide to the Bash Terminal for Beginners

Below is a list of most common commands:

NAVIGATION

  • ls - list directory contents
  • pwd - print name of current/working directory
  • cd - change working directory
  • pushd/popd - put the working directory on a stack
  • file - determine the file type
  • locate - find files by name
  • updatedb - update database for locate
  • which - locate a command
  • history - display bash command history

GETTING HELP

  • whatis - display the on-line manual descriptions
  • apropos - search the manual page names and descriptions
  • man - an interface to the on-line reference manuals

WORKING WITH FILES

  • mkdir - create a directory/make directories
  • touch - change file timestamps/create empty files
  • cp - copy files and directories
  • mv - move (rename) files
  • rm - remove files or directories
  • rmdir - remove empty directories

TEXT FILES

  • cat - concatenate files and print on the standard output
  • more/less - file perusal filter for CRT viewing
  • nano - command line text editor

USERS

  • sudo - execute a command as the superuser
  • su - change user ID or become another user
  • users - print the usernames of users currently logged in
  • id - print real and effective user and group IDs

CHANGING FILE PERMISSIONS

  • chmod - change permissions of a file

KILLING PROGRAMS AND LOGGING OUT

  • Ctrl+C - kill a running command
  • killall - kill processes by name
  • exit - log out of bash

How to check if a package is installed on Linux

On RPM based system
on RPM based systems like Red Hat, Cent OS etc, we can use rpm query command like below :
rpm -qa | grep telnet
or 
rpm -q telnet

If system is configured with YUM then it can list all installed packages for you and you can grep out your desired package from it.
yum list installed | grep telnet

On APT based systems 
on APT based systems like Debian, Ubuntu etc, dpkg command can be used to verify if package is installed
dpkg -l | grep telnet