Linux and Shell Commands
Linux and Shell Commands
By
MANOJ AP
http://ubuntu.com
Request for a free Ubundu Linux CD
Beginners of Linux has two option to learn installing OS to the computer or rely on
Live CD,. Knoppix , Ubundu, Morphix etc are the famous Live CD available today. You
can request for a CD through website or just download the ISO image of the OS and burn
it to a CD. Then you can use these CD’s to Run Linux from CD (All you have to do is
reset your First booting Device as CD/DVD in BIOS settings, this section can be reached
pressing Del/F1 key). This did not harm your computer OS either.
Linux is famous for multi choice and multi-user facilities. Linux has a rich set of GUI
Application as in the other OS such as Micro Soft Windows, Mac OS etc. It also provides
different shells in which user can run commands and applications. This section is similar
to MS DOS.
What is shell?
• A program that interprets commands/It’s a command line interpreter / Environment for
user interaction
Shell itself is not Kernal but it is the interface between Kernal and user, it uses
kernel to execute commands. Linux is multi choice system. Following are the
popular Linux shell programs.
Various Shells
• tcsh
• csh
• bash
• ksh
What is BASH?
Case Sensitivity - In Linux/UNIX, commands and file names are case sensitive, meaning
that typing “EXIT” instead of the proper “exit” is a mistake.
“\” vs. “/” -In DOS, the forward-slash “/” is the command argument delimiter,
while the backslash “\” is a directory separator. In Linux/UNIX, the “/” is the directory
separator, and the “\” is an escape character._
Filenames : The DOS world uses the “eight dot three” file name
convention,Meaning that all files followed a format that allowed up to 8 characters in the
filename, followed by a period (“dot”), followed by an option extension,up to 3
characters long (e.g. FILENAME.TXT). In UNIX/Linux, there is no such thing as a file
extension. Periods can be placed at any part of the filename, and “extensions” may be
interpreted differently by all programs, or not at all.
Special Characters
Before we continue to learn about Linux shell commands, it is important to know that
there are many symbols and characters that the shell interprets in special ways. This
means that certain typed characters: a) cannot be used in certain situations, b) may be
used to perform special operations, or, c) must be “escaped” if you want to use them in a
normal way.
\ Escape character. If you want to reference a special character, you must “escape”
it with a backslash first.
Example: /usr/src/linux
. Current directory. Can also “hide” files when it is the first character in a filename.
.. Parent directory
Example: ls | more
> Redirect output of a command into a new file. If the file already exists, over-write
it.
>> Redirect the output of a command onto the end of an existing file.
&& Command separator as above, but only runs the second command if the first one
& Execute a command in the background, and immediately get your shell back.
Many commands have simple “help” screens that can be invoked with special command
flags. These flags usually look like “-h” or “--help”.
The best source of information for most commands can be found in the online manual
pages, known as “man pages” for short. To read a command's man page, type “man
command”.
Directory Description
The nameless base of the filesystem. All other directories, files, drives, and devices are
attached to this root. Commonly (but incorrectly) referred to as the “slash” or “/”
directory. The “/” is just a directory separator, not a directory itself.
/bin Essential command binaries (programs) are stored here (bash, ls, mount, tar, etc.)
/dev Device files. In Linux, hardware devices are acceessd just like other files, and
/tmp Temporary files. All users have permission to place temporary files here.
/usr The base directory for most shareable, read-only data (programs,
libraries,documentation, and much more).
/usr/bin Most user programs are kept here (cc, find, du, etc.).
/usr/local “Locally” installed files. This directory only really matters in environments
where files are stored on the network. Locally-installed files go in /usr/local/bin,
/usr/local/lib,etc.). Also often used for software packages installed from source, or
software not officially shipped with the distribution.
/usr/src Program source code. E.g. The Linux Kernel, source RPMs, etc.
/usr/X11R6 The X Window System.
/var Variable data: mail and printer spools, log files, lock files, etc.
export Set the value of a variable so it is visible to all subprocesses that belong
to the current shell.
set Shows how the environment is set up. This is a builtin bash command.
Library management
ldconfig Updates the necessary links for the run time link bindings.
dmesg Print or control the kernel ring buffer. This shows the last kernel startup
messages.
modprobe Used to load a set of modules that are marked with a specified tag.
rmmod Unload loadable modules.
shutdown If your system has many users, use the command "shutdown -h
+time message", where
time is the time in minutes until the system is halted, and message is a short
explanation of why the system is shutting down.
# shutdown -h +10 'We will install a new disk. System should be back on-line in
three hours.' telinit By requesting run level 1 a system can be taken to single user
mode.
the location of the keyboard map file. This is a GUI based tool.
ndc Script file used to restart, stop, start the DNS server.
samba Script file used to stop, start, restart samba services when not run using
inetd.
lsdev Display information about installed hardware via files in the /proc directory.
System Logging
klogd Kernel log daemon which intercepts and logs Linux kernel messages.
System Security
System time
cal Calendar.
clock Used to change or get current time. The command "clock -–w" sets the
hardware clock.
timed Time server daemon to synchronize the host's time with other machines,
normally invoked at boot time from the rc(8) file.
tzset Used to change the users private time zone by setting the TZ environment
variable.
zdump Prints the current time in each zonename named on the command line.
zic Reads text from files named on the command line and creates time
conversion files.
XF86Setup A newer X configuration program with a GUI interface which modifies the
"/etc/X11/ XF86Config" configuration file.
xvidtune This program will test video modes on the fly without modification to your X
configuration. Read the usr/X11R6/lib/X11/doc/VideoModes.doc file before running this
program.
adduser Ex: adduser mark - Effect: Adds a user to the system named mark
chage Used to change the time the user's password will expire.
edquota Used to edit user or group quotas. This program uses the vi editor to edit the quota.user and
quota.group files. If the environment variable EDITOR is set to emacs, the emacs editor will be used. Type
"export EDITOR=emacs" to set that variable.
grpconv Creates /etc/gshadow from the file /etc/group which converts to shadow passwords.
grpunconv Uses the files /etc/passwd and /etc/shadow to create /etc/passwd, then deletes /etc/
lastb Shows failed login attempts. This command requires the file /var/log/btmp to exist in order to work.
Type "touch /var/log/btmp" to begin logging to this file.
lastcomm Display information about previous commands in reverse order. Works only if process
accounting is on.
quotacheck Used to check a filesystem for usage, and update the quota.user file.
sa Generates a summary of information about users' processes that are stored in the /var/log/pacct file.
smbclient Works similar to an ftp client enabling the user to transfer files to and from a windows based
computer.
smbmount Allows a shared directory on a windows machine to be mounted on the Linux machine.
su Ex: su mark - Effect: changes the user to mark, If not root will need marks password.
ulimit A bash builtin command for setting the processes a user can run.
Ex: lpr -Pdest filename. Dest is the destination printer. the name of the file to print
is filename.
lpc Lets you check the status of the printer and set its state.
Linux Programming
as86 Assembler
awk C programming language - allows finding of lines with specific characters.
cproto Reads in c source files and generates function prototypes for all the
functions.
cb - C program beautifier
SPARC systems
squeak - smalltalk
-pg Generate profile info that will allow the gprof program to display timing info.
gprof In /usr/bin, allows you to tell where most of the execution time is spent in a
program.
indent Reformats c source code for consistent indenting and opening and
closing bracketsconsistent.
prompt set prompt = "waldo" (in C shell) ps1 = 'waldo' (in BOURNE shell)
PS1="[\u@\h \w]\\$ " makes prompt = [username@hostname current directory]
see the BASH or your shell's man page for more information.
Scripting Languages
Perl A command interpreter for the Practical Extraction and Report Language
(perl).
Python A report language.
Tcl Tool command language shell. Enter by typing tclsh.
info Return information about the state of the Tcl interpreter.
Tk A graphical user extension to Tcl based on X windows. Commands are same
as Tcl.
Database Management
Mysql, Oracle and informix are available.
setoracle - set up oracle environment and path on Suns
slplusq - run the Oracle SQL interpreter
sqlldr - run the Oracle SQL data loader
mysql - run the mysql SQL interpreter
Ncurses functions
Rebuild Kernel
Configure Kernel Parameters
make config
make menuconfig
make xconfig
Configuring the kernel with interactive, menu or X window interface.
make dep
make zImage
make zdisk
make zlilo
make bzImage
Compile Modules
make modules
make modules_install
Building and installing modules.
X Window (XFree86)
eqn Format equations for troff. Compiles descriptions of equations embedded in troff.
geqn Used to print special symbols and complex equations. Not user friendly.
grodvi Convert Groff output to TeX dvi format, normally run by groff.
groff Used as a front end for the groff document formatting system.
lookbib Search
bibliographic databases.