Thursday, September 20, 2007

PCLinuxOS Command Line Basics

image of a typical xterm
image of a typical xterm in pclinuxos

PCLinuxOS tries to serve everything on the face, i.e., desktop. But as you grow using it, you will definitely like to use its terminal (Konsole, Xterm or Yakuake). Knowledge of the following CLI (Command Line Interface) commands will definitely enhance your experience of the terminal.

As a background to CLI, please understand these bash notations:

/ - root directory
./ - current directory
./command_name - run a command in the current directory when the current directory is not on the path
../ - parent directory
~ - home directory
$ - typical prompt when logged in as ordinary user

A few keyboard shortcuts to CLI operations:

[Tab][Tab] or [Esc][Esc] - prints a list of all available commands.
x[Tab][Tab] or x[Esc][Esc] - prints a list of all available completions for a command, where the beginning is 'x'.
[Alt][Ctrl][F1]-[F6] - switch to the virtual text console.
[Alt][Ctrl][F7]-[F12] - switch to the GUI console, if there is one running.
[Arrow Up] - scroll through the command history.
[Shift][Page Up] - scroll terminal output up.
[Shift][Page Down] - scroll terminal output down.
[Ctrl][Alt][Bk Spc] - kill the current X server. Used when a normal exit is not possible.
[Ctrl][Alt][Del] - shut down the system and reboot.
[Ctrl]c - kill the current process.
[Ctrl]d - logout from the current terminal.
[Ctrl]s - stop transfer to current terminal.
[Ctrl]q - resume transfer to current terminal. This should be tried if the terminal stops responding.
[Ctrl]z - send current process to the background.

pclinuxos konsole terminal
image of a typical konsole in pclinuxos

List of Linux Bash Commands

access  - determine whether a file can be accessed.
Usage: access -MODE FILE MODE is one or more of rwx.
Exit successfully if FILE exists and is readable (r),
writable (w), or executable (x).

adduser - used by root to add user to system

Usage: useradd [options] LOGIN

agetty    - enables login on terminals.

Usage: agetty [-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] baud_rate,... line [termtype] or [-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... [termtype]

ark       - create, modify and extract from archives

Usage: Calls Gui Ark

arch      - print machine architecture type
bash      - Bourne again shell. This is the default shell

Usage: bash [GNU long option] [option] ... bash [GNU long option] [option] script-file ... Type `bash -c "help set"' for more information about shell options. Type `bash -c help' for more information about shell builtin commands.

bunzip2   - used to uncompress files compressed with bzip2

usage: bunzip2 [flags and input files in any order]

bzip2     - compresses with algorithm different from gzip

usage: bzip2 [flags] file name

bzless    - view bzipped files

usage: bzless /folder/

bzcat     - view bzipped files

Usage: bzcat /folder/

cd        - change working directory.

Usage: cd dir

cfdisk    - hard drive partion configurator

Usage: cfdisk

chgrp     - changes group associated with file. Can be used to change the group
associated with subdirectories and files of a directory.

usage: chgrp group files or: chgrp -R group files
chkconfig - Query or update system services/daemons for different runlevels.
chmod     - set permissions (modes) of files or directories.

A value of 4 is used for read permission. A value of 2 is used for write permission. A value of 1 is used for execute permission.

chown     - changes ownership of a file. Can be used recursively.

usage: chown userid files or: chown -R userid files

clear       - clear screen command

usage: clear

cmp         - compares two files for differences

usage: cmp file1 file2 cmp /etc/X11/xorg.conf /etc/X11/xorg.conf.old

cp        - copies on or more files. Recursive copying is one simple way of
archiving part of a directory structure.
Use the command as follows: cp -r /sourcedirectory /targetdirectory
date      - displays or sets date and time

usage: date

diff      - displays differences between two files

usage: diff file1 file2 (same as cmp)

dmesg     - displays messages from /var/log relative to the most recent boot

Usage: dmesg [-c] [-n level] [-s bufsize]

e2fsck    - check an ext2 filesystem. The syntax is e2fsck /dev/devicename
where the filesystem is on /dev/devicename. The device should not be
mounted, and this program must be run as root.
echo      - write arguments to standard output. One use is to print out information
about environment variables,
as in echo $PATH - list paths to search
echo $HOME or echo ~ - list name of home directory
egrep     - search files for lines that match regular expressions.

Runs faster than grep and fgrep.

exit      - exit a shell. This is a shell builtin.

fdformat - low level format of a floppy device

file - displays classification of a file or files according to the type
of data they contain
find      - find files according to a large variety of search criteria.

The find command that I use the most is find . -name filename -print

grep      - used to find a string within a file. The -i option returns matches
without regard to case. The -n option means that each line of
output is preceded by file name and line number. The -v option
causes non-matched lines to be printed.
usage: grep pattern files or: grep -i pattern files
or: grep -n pattern files or: grep -v pattern files
groupadd  - create a new group on the system

groups - shows which groups you are in

gunzip - used to uncompress files compressed with gzip

gzip - used to compress or decompress files

halt - immediately shut down system as root, without reboot

history - command for viewing and manipulating the shell command history list
ifconfig  - display (as root) information on network interfaces that are
currently active. First ethernet interface should be listed as eth0,
second as eth1, etc. First modem ppp connection should be listed as
ppp0, etc. The lo connection is loopback only.

ifdown    - shut down the network interface

ifup [interface_name] - start up the interface

insmod - used (by root) to install modular device drivers
kill      - sends a signal to (especially to terminate) a job or process.

This is a shell builtin in bash,tcsh and zsh.

killall   - kill processes by name. Kill all processes which are instances
of the speciffied program. Also used to send signals to processes
or restart them.
killall5  - kill all processes except the ones on which it depends

less - Linux alternative to more command. Displays text files,
screenful at a time. When less pauses, there is a large number of
available commands to tell it what to do next. One can scroll both
forwards and backwards.
ln        - creates a link to a file. Used to create hard links and,
with the -s option, symbolic links which can link files on
different disk partitions. The syntax is - ln [options] source [dest]
logout    - execute logout as individual user and bring up login: prompt

ls - list directory contents.

lsmod - used (by root) to show kernel modules currently loaded

lspci - utility to display information on pci buses and
hardware devices attached to them.
man       - displays information from online Unix reference manual

mkdir - create a directory

mkfs - create a file system (format) on a device or partition.

Should be invoked after lowlevel formatting of the disk using fdformat. It has several versions which are all links to the basic program, such as mkfs.ext2

more      - list file contents, stopping after each full screen
mount     - mount device using filesystem of type [fstype] with device name

[device] at the location [mountpoint] in the filesystem directory tree mount -a - mount all filesystems according to the specifications in /etc/fstab

mv        - moves (renames) files

usage: mv [src] [dest]

passwd    - change login password

pwd - print absolute path of working directory. This is a shell builtin.

reboot - reboots the system. Seems to be equivalent to shutdown -r now

rm - remove files or directories. With the -r (recursive) option
(very dangerous!), can be used to remove the contents of a
specified directory including all subdirectories.
rmdir     - remove empty directories

showmount - show information about an nfs server

shutdown - reboot or shut down system as root, after specified amount of time.
With the -r option, reboot. With the -h option, halt the system.
usage: shutdown -r minutes
startx    - front end to xinit in Linux. This is a script which starts up X clients
and shuts down the X server on exit from the window manager
su        - log in as another user, including root

sudo - allows individual users to have root permission to perform specified
umount [device] - finish writing to the device and remove it from the active
filesystem. The command umount -a will (re)mount all file systems
listed in /etc/fstab.

unzip - uncompress files compressed with the zip utility,
compatible with DOS PKzip

userdel - remove an account (as root). The user's home directory
and undelivered mail must be dealt with separately.
users     - prints list of users on the system

which - used to find utilities in search path. Will return the absolute
directory path of the named utility program.

who - display information about currently logged in userids

whoami - display information about userid that is currently logged in

X - starts up the X server. Same as startx

There are many commands available on your PCLinuxOS system. Not all commands have a man page. To see a complete explanation for using a command, in a terminal window enter man command_name, where command_name is the actual name of the command. For any command not containing a man page, command_name --help will usually show a summary of command options.

For more information visit



jonathan said...

thanks a lot for posting the most essential and fundantal commands. new pclinuxos users like me will definitely be enlightened.

sudhansu said...

would you please elaborate on the enterprise usage of the suite?

krushna said...

plz divide the commands as per their usage in desktop and server.

manmath sahu said...

main purpose of this pclinuxos blog is to cater to the need so desktop users, hence there is few chance of any server related literature here.

vikash ranjan jha said...

how to configure server on pclinux can you please explain

How about this