Monday, 16 July 2012

Useful Linux Commands

Linux Commands Documentation
Starting with A
# a2ps- Formats files for printing on a PostScript printer
# AMSTeX- formatting documents with TeX, AMS version
# AMSLaTeX- AMS version of LaTeX
# at- allows you to run programs at a later date
# awk- pattern scanning and string manipulation language, developed by GNU. See also mawk, a POSIX implementation of awk
Starting with B
# bash- The bourne again shell, one of the two basic ways you interact with the computer, the other is the tcsh shell
# bc- an arbitrary precision calculator. If you want a calculator for X-windows try xcalc
# bibtool- BibTeX file manipulation tool
# bison- the YACC-compatible Parser Generator
# bzip2- a file compressor
Starting with C
# cdrecord- record audio and data Compact Discs. There is also a graphical program called xcdroast
# chmod- to change permissions of files
# chown- to change ownership of files
# chktex- finds LaTeX errors
# cjpeg- compress an image file to a JPEG file
# clisp- common Lisp language interpreter
# cmp- compares two files.
# convert- converts between different formats of image files
# cpio- copy files to and from archives
# cp- to copy one file into another
# cpp- the GNU C preprocessor
# cron- to run programs periodically (as opposed to at, which run them just once); this link contains the format of the control file.
# csh- the C shell
Starting with D
# date- shows (and sets up, for the super user) the system date
# dc- an arbitrary precision calculator; see also bc
# ddd- Data Display Debugger, the debugger for gcc (GNU C compiler)
# diff- shows the differences bewteen two files; see tkdiff for a graphical program that does a similar job and zdiff to look at differences between compressed files
# dqs- a batch queueing system that allows to queue jobs (programs) in different machines to be run according to the load of the machines. You can check also reference guide. See also queue
# dvips- converts files from TeX DVI format to PostScript
Starting with E
# elm- a program to read/send email for UNIX:
# emacs- the GNU editor where all started… There is a similar program for X-windows (graphical interface) called xemacs
# expect- a toolf fo rautomating interactive applications such as telnet, ftp, rlogin, etc (the Frequently Asked Question file)
# egrep- searches one or more input files for lines containing a match to a specified pattern
Starting with F
# flex- fast lexical analyzer generator, or a tool for generating programs that performs patter-matching on tex.
# ftp- the File Transfer Program, that allows the transfer of file between computers connected to the Internet (or some sort of network)
# find- searchs for files in a directory
# free- show how much memory is being used and how much is free in the system
# fromdos- converts a file from DOS format to UN*X format; the reverse process is done with todos
# fvwm95- a X-windows manager that will make your computer look like Windows’95: here you have an example of a configuration file
Starting with G
# g++ – the GNU C++ compiler (it is also the GNU C compiler)
# gimp- an image manipulation and paint program
# g77- the GNU Fortran compiler
# gawk-same as awk above
# gcc- the GNU C compiler
# giftrans- allows to put transparent or background colors on GIF files
# gmp- the GNU multiple precision arithmetic library, to write C programs with arbitrary precision
# grep- same as egrep above
# gdb- Data Display Debugger, same as ddd above
# gs- a PostScript and PDF language interpreter and previewer
# gsl- the GNU Scientific Library, for writting programs in C
# gv- a previewer for PostScript and PDF files
# gzip- compress files
Starting with H
# hcc- a brief reference to C/C++ compiler for LAM (parallel compiling)
# head- show the beginning (head) of a file
# hexdump- gives the hexademic format of files in the computer
# host- a program to find addresses (and other data) of computers connected to the Internet
Starting with I
# indent- a program that makes C code easier to read and converts from one style of writing C (eg. GNU, Kernighan & Ritchie, Berkeley) to another
# Imagemagick- a program to display and manipulate image files
# imake- the make command for X11 (manual page formatted on html)
ispell, a spell checker
# imp- a program to read your mail via a web browser (like Netscape)
Starting with K
# kill- stops processes running in a computer
# killall- kills processes by name
Starting with I
# latex- to format documents, especially mathematics; quite complete user’s guide. If you want to find a particular symbol you can check this table of LaTeX symbols
# latex2html- converts from LaTeX to HTML (web based files)
# less- a command to look a files (a PAGER, in UN*x language)
# lpq- the command to look at the printer queue
# lpr- the command to print
# ls- to list contents and information of files and directories
# lynx- a text-based browser, useful for example for pages with too many graphics or bad Java scripts (or if you want fast browsing)
Starting with M
# magma- a Computer Algebra system for solving problems in algebra, number theory, geometry and combinatorics (works only in prime). For the full documentation you can start with link
# mailx- the basic UNIX command to send/read mail
# make- a tool to generate execuatable files from a program’s source files
# man- the program to look at manual (help) pages of Linux/UN*X commands
# mathematica- a commercial program for mathematical computations
# maple- another commercial program for doing mathematical computations
# mawk- an implementation of awk (pattern scanning and string manipulation language) that tries to follow the POSIX standard. See also awk, the GNU implementation of awk
# mc- the Midnight Commander, a directory/file manager for UN*X operating systems
# mkisofs- program used to create file systems to later write them on CDs
# montage- creates a composite image by combining several separate images
# more- a program that allows you to look at files (like less, but no so powerful)
# mtools- a set of programs that allows you to handle DOS files and directories, in particularfloppy disks. The most common commands are the following:
# mcd- to change directories
# mcopy- to copy between DOS and Linux files
# mdel- to delete DOS files
# mdir- to make DOS directories
# mdu- to check the usage of DOS files in a floppy/file system
# mformat- to format a floppy to be used as DOS floppy later
# mv- renames files
Starting with N
# ncftp- a powerful interface for using ftp (File Transfer Protocol)
# newalias- install new elm aliases
# nice- makes processes to run on low priority so the system can do more impotant tasks. If the process is already running you can use the command renice
# nsloopup- a program to find addresses (and other data) of machines connected to the Internet. Note: better use the program “host” as this program might disappear in the future
Starting with P
# pari- software package for computer-aided number theory, consisting of a C library (to write your own programs) and an interactive calculator called gp
# pdflatex- produces PDF output (instead of standard dvi file) from a LaTeX file
# pdftex- produces PDF output (instead of standard dvi file) from a TeX file. You can check a sample document here
# pdftops- converts PDF (Portable Document Format) files to PostScript so they can be printed.
# pftp- the same as ftp but called in a “passive” way, good for example when two computers are connecting with firewall between them.
# pico- a simple editor that comes with the “pine” package
# pilot- a file browser in the style of “pine”
# pine- a popular program to read email. The documentation for the latest version (“pine 4″) is available: pine4. Check also elm, another popular email program.
# pmake- a version of make, that is, a tool to generate execuatable files from a program’s source files
# ps2pdf- converts PS files to PDF files
# psselect- select pages from a PS file (for example, to print only certain number of pages)
# psbook- arranges pages in a PS file so the print out looks like a book
Starting with Q
# queue- allows to queue jobs (programs) in different machines to be run according to the load of the machines. See also dqs
# quota- displays users’ disk usage and limits
Starting with R
# rcs- Revision Control System, a program that allows you to keep different versions of a file/document in a single “control” file; good, for example, when you are editing a file very frequently and do not want to have too many files with similar names
# renice- to change priority of running processes, so they can be slowed down allowing the system to work faster on more important tasks. You can look at the information about nice command that allows you to start a process with low priority.
# rm- deletes files
# rsh- remote shell, allows you to login or execute programs in a remote computer
Starting with S
# scanimage- a simple command-line (no graphical interface) program to interact with a scanner. See also
# xscanimage- the command with graphical interface
# sendfile- a program to send files via Internet
# setterm- changes the properties of the terminal (“screen”), like number of lines/rows, automatic line wrap, etc
# shar- creates shell archives (shar files); these are packed files that can be unpacked later in a simple way bu executing a command. The packed files can be send by email
# sleep- delays for a specified amount of time (it does nothing for some time, hence the name of the program)
# sort- sorts lines in a text file
# spell- a UN*X spell emulator, simpler and less powerful than ispell
# split- splits a file into smaller files, good for example to send small files by email
# ssh- the Secure Shell, allows you to execute commands or login in a remote computer in a secure (crypted) way. It should be prefereed to the rather equivalent, non-secure, rsh
Starting with T
# tail- shows the end (tail) of a file
# tar- a program to create and manipulate archives (“tar files”) which are actually collections of many other files
# tcsh- a very popular shell (that is, the basic program that allows you to execute commands, and it is the one you run after login in the system). An example of a configuration file can be found here. The other popular shell is bash
# tee- reads from standard input (basically keyboard or a file) and writes to standard output (screen) and files; good if you want to write something to a file and see what is written at the same time
# telnet- allows you to log on in a computer conneted to the Internet or a local network
# telnet-ssl- like telnet above but with crypted communication, to increase security
TeX, to typeset mathematical documents; this is the manual page of the command “tex”; there is lot of documentation in the Internet
# time- runs programs and tells how much time (real time and computer usage) they take
# tkdesk- a Graphical File and Desktop Manager for X-windows
# tkdiff- this program displays in a nice, graphical way, the differences between two files
# tkdvi- a dvi previewer based on tcl/tk, adds some features to the standard dvi previewers like xdvi
# todos- converts a file from UN*X format to DOS format; the reverse process is done with fromdos
# top- shows processes running, displaying the most CPU-intensive tasks, and allows renice and kill them
# touch- allows to change the timestamps of files
# traceroute- finds the route that packets take between your computer and another computer connected to the Internet or a local network. It might not work if your computer is behind a firewall that does not allow ping (for security reasons)
# transfig- creates a make file to translate figures in FIG code to LaTeX
# tree- lists all the files in a directory in a tree-like format
Starting with U
# uname- gives information about the machine you are working on, like hardaware type, name, processor, operating system.
# uname- gives information about the machine you are working on, like hardaware type, name, processor, operating system…
# untex- removes LaTeX commands from a file
# unzip- extracts or lists the files in a “qip” archive (a type of file that has many files within it)
# uuencode- puts a binary file in an encoded format so it can be sent over email as a simple text file; the reverse process is done with uudecode. Nowadays most mail programs can do similar things via MIME without need for the user to do any extra processing
# untex- removes LaTeX commands from a file
# unzip- extracts or lists the files in a “qip” archive (a type of file that has many files within it)
# uuencode- puts a binary file in an encoded format so it can be sent over email as a simple text file; the reverse process is done with uudecode. Nowadays most mail programs can do similar things via MIME without need for the user to do any extra processing
Starting with V
# vacation- returns a message to senders of an email telling them that you are currently not reading your mail (“on vacation”)
# vi- the classical (and for some people obsure) UN*X editor; if you want a more advanced help you can check this document. Other editors are emacs, pico and xemacs
# vlock- a program to lock one or more sessions on the Linux console
Starting with W
# w- shows who is logged in a computer and what they are doing
# wall- writes a message to all users logged on in a computer
# wc- computes the number of bytes, words and lines in files
# wdiff- displays word differences between text files
# wget- a command to get files from the World Wide Web without using a browser (that is, without netscape, lynx, etc, just a plain command)
# whiptail- display graphical boxes from scripts
# workman- a graphical program to play audio compact discs
Starting with X
# xcal- calendar with alarms and a notebook for X-windows
# xcalc- a scientific calculator for X-windows. See also bc, an arbitrary precision calculator program
# xcdroast- a graphical program to write CDs. See also the more basic, command-line program cdrecord
# xclock- a digital/analog clock for X-windows
# xcolors- displays all the X-windows colors names
# xcolorsel- displays all the X-windows colors names in many formats
# xemacs- a version of emacs for X-windows. You can also access two documentation files in PDF format: the new users’ guide and the more advanced users’ guide
# xfig- a tool to create figures under X-windows (that can be later included in LaTeX files, for example). You can also access the same documentation in a fancier format (frames)
# xfontsel- a program to help you to select fonts for X-windows
# xfreecd- a X-windows program that looks like the frontpanel of a CD player and, as you might expect, plays audio CDs
# xhost- this program is used to add/delete hosts/users names authorised to display windows in your computer
# xlock- program to lock your X-windows session
# xmake- another make utility; check also imake and make
# xman- displays manual pages in a windows environment
# xmcpustate- shows usage of CPU
# xpaint- a graphics program to draw pictures under X-windows; you can save the files in many different formats (including gif and jpeg)
# xpdf- a program to display PDF files; see also gv
# xscanimage- a graphics-based command to use a scanner; see scanimage for a non-graphics command.
# xset- sets preferences for X-windows sessions
# xsysinfo- displays technical information about memory, CPU and other stuff in your machine
# xterm- the “basic” X-windows programs, like a shell, from which you can call any other program
# xxgdb- Data Display Debugger in for X-windows
Starting with Y
# yppasswd- the basic command to change your password in our system (or any system running NIS)
# ytree- a basic file manager that displays the files in a directory in a tree-like form. See also the Midnight Commander
Starting with Z
# zcat- allows you to look at a compressed file
# zdiff- shows differences between two compressed files; see also diff for looking at differences between two “regular” files and tkdiff for a nice graphical program that shows differencese between two “regular” files
# zip- creates ZIP archives, that is files that contain other files inside; see also tar and cpio, two programs that create archives

Useful Linux Commands
To view System Resource Information
uname --help
uname -r
grep model /proc/cpuinfo
grep MemFree /proc/meminfo
sudo -u root lastcomm -f /var/account/pacct
cat /proc/version
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts
cat /etc/redhat-release
grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo
df -k /tmp
grep "model name" /proc/cpuinfo
ifconfig (/sbin/ifconfig)
uaname -r
lshal:detected hardware
rpm -qa:  display pakage
rpm -qa | less

Linux Kernel Information:
cat /etc/sysctl.conf
cat /etc/hosts
Uname -r
cat /etc/security/limits.conf
cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
cat /proc/sys/kernel/shmall
cat /proc/sys/kernel/shmmni
cat /proc/sys/fs/file-max
cat /proc/sys/net/ipv4/ip_local_port_range
cat /etc/issue
sysctl -a | grep shm
sysctl -a | grep ip_local_port_range
/etc/inittab:  init process determines which runlevel it should be 
w, ps -a, ps -Alf, ps -AlFH, ps -AlLm
ps -u oracle, ps -u anguyen
Commands to monitor bottlenecks such as Disk, Memory / CPU/Network, or System Activity:
top ? t, m, A: top consumer, r: renice, o: interactively select
vmstat 3, vmstat -m:memority slab info, vmstat -a
w, ps -a, ps -Alf, ps -AlFH, ps -AlLm
ps -u oracle, ps -u attunity
fee -s 2
watch -n 3 -d free
watch -d cat /proc/meminfo
sar -B -f /var/log/sa/sa14
sar -W -f /var/log/sa/sa14
vmstat -m
vmstat -a
ipcs -sm
ipcs -lms
sar -n DEV | more
sar 4 5
mpstat -P ALL

MEMORY intensive process:
ps -e -o pmem,pid,user,tty,args | grep -i oracle | sort -n -k 1 -r | head
watch -n 3 -d free
watch -d cat /proc/meminfo

CPU intensive process
ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head
mpstat -P 0 2 20 (processor 0
mpstat -P ALL
sar -u -f

Disk Storage
iostat -d 3, iostat 2 15
iostat -xd 10

sorting files by size
ls -alS | head -5
mpstat -P ALL
sar 4 5
lsmod | grep -i bonding
cat /etc/sysconfig/network-scripts/ifcfg-eth0 (check bonding)..the difference NETWORK, IPADDRESS, NETMASK
netstat -s | less
netstat --interfaces eth0
netstat -ptc
sar -n DEV
netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq
tcpdump -n -i eth1 -s 0 -w output.txt src or dst port 80
iptraf - Real-time Network Statistics

Network traffic
netstat -ptc
sar -n DEV
sar - Collect and Report System Activity
cpio -idmv < 10201_database_linux_x86_64.cpio
id oracle
id nobody
pgrep sshd
env | grep PATH
detected hardware lshal: 
init process determines which runlevel it should be /etc/inittab
shutdown -t3 -r now
mount /dev/hda4 /data/oracle/bkup1:
 grep ‘Ashley Nguyen’ /etc/passwd
find / -name install.log
sed ‘s/anguyen/lvu/’ /etc/passwd > /tmp/test
ps aux | grep nfs
Ifconfig -a
To determine the amount of shared memory available, enter the following command:automatic memory management
# df -k /dev/shm/
To determine the distribution and version of Linux installed, enter the following command:
# cat /proc/version
To determine whether the required packages are installed, enter commands similar to the following:
# rpm -q package_name
Add group
# /usr/sbin/groupadd oper
Modify user:  usermod -g oinstall -G dba oracle
Create disks:
fdisk -l
give password to oracle user
passwd oracle
change ownership in linux
clear screen 
TAR - backup / restore
tar -cf myfiles.tar *.trc (create)
tar xvf myfiles.tar (extract)
tar tvf myfiles.tar (show the details

No comments:

Post a Comment