Thursday, December 17, 2009

Saturday, April 4, 2009

ECHO command

echo $SHELL = prints the default shell name
echo $OSTYPE = prints the operating system name
echo 'text' = prints what is held in the quotes
echo $HOME = prints home directory
echo $USER = who is currently using the system
echo $HISTFILE = location of history file
echo $HISTFILESIZE = history's set size
echo $HISTSIZE = history's set size
echo “test” | mail -v -s test xyz@abc.com = sending e-mail from a terminal

MAN command

man -f php = info about php modules
man -k php = info about php modules
man php = php manual pages
man man = info about manual pages and their format
man 3 php = shows entries for php in 3rd section of the manual
man php | grep word = searches for a particular word in php manual
man hier = info about directories

LSPCI command

lspci = info about pci devices/ports
lspci | grep VGA = graphics card info
lspci | grep audio = audio card info
lspci | grep -i modem = modem info
lspci | grep -i usb = usb ports info
lspci | grep -i ethernet = ethernet card info

LS command

ls /var/www/html/*.html = lists all html files
ls .??* = lists all directory names that start with a dot .
ls /etc/rc.d = prints all directories for all available run levels
ls /etc/rc.d/init.d = list of system services' scripts
ls -l = lists files and folders in the current directory
ls -la = lists files and folders in the current directory with a dot
ls li = files with their inodes
ls -lt = files recently modified
ls -lu = lists files by their accss time
ls -ln = user names and groups numerically displayed
ls -lh = human readable file sizes
ls -lR = displays all the files and their folders
ls -F = lists files by type
ls -c = lists files columnwise
ls –color =always = shows filenames in colors

ls -l /var/lib/rpm = rpm database
ls = lists contents of a directory
ls . = lists contents of a directory
ls .. = lists contents of a directory
ls / = lists all system directories
ls = lists directories in current directory
ls /var = lists all subdirectories under the /var directory
ls /proc | wc -l = number of subdirectories in /proc directory
ls -ltr =
ls -l filename.ext = checks permissions for a file
ls -l /etc = permission status of all subdirectories
ls -a = shows hidden . Dot directories. A kind of special configuration files not be messed with

LOCATE command

locate xyz = locates file xyz case-sensitive
locate -i xyz = locates file xyz not case-sensitive
locate -r /ls$ = locates files ending in /ls
locate -r james*bond = locate files with james and bond in their names
locate -r ^ boot/grub/me = locate files beginning with boot/grub/me
locate *.jpg > Desktop/myjpgs.txt = stores results of search in a file named myjpgs.txt

HISTORY command

history | wc -l = total history commands
history | grep rpm = search through history for rpm commands
history = list of all commands used so far

DMIDECODE command

dmidecode = BIOS info
dmidecode | head -n10 = first 10 lines of BIOS info
dmidecode –-type baseboard = baseboard info
dmidecode –-type cache = cache info
dmidecode –-type chassis = chassis info
dmidecode –-type connector = connector info
dmidecode –-type memory = memory info
dmidecode –type processor = processor info
dmidecode –-type slot = slot info
dmidecode –-type system = system info
dmidecode –-type wrongtype = gives right words/types

CAT command

cat /var/log/yum.log
cat /var/log/yum.log | grep mysql = mysql install and update dates
cat /proc/meminfo = prints memory info
cat /proc/cpuinfo = prints cpu info
cat /var/log/manylogs/mylogonly.log = prints output of a file
cat /selinux/enforce = current status of selinux
cat /etc/shells = lists all installed shells on the os
cat /etc/inittab = info about run levels
cat filename | sort = sorting output in alphabetical order
cat /etc/x11/xorg.conf = monitor info
cat filename1 filename2>filename3 = merges the files
cat /etc/fstab = list of all devices
cat /etc/filesystems = of file systems
cat /var/log/messages | grep -F ntpd =

Saturday, March 21, 2009

Permissions in Fedora Linux

Permissions:

rwx rwx rwx
1 2 3
u g o

u = user
g = group
o = other
r = read = 4
w = write = 2
x = execute = 1

SERVICE command

service httpd start = starts apache server

service mysqld start = starts mysql server

service --status-all = service status of all the services installed

YUM command

yum clean all =
yum clean headers =
yum clean metadata =
yum clean packagename = clean packages left in cache
yum –enablerepo =livna install mplayer = enable livna repo & install mplayer
yum --disablerepo = livna search php = disable livna repo and search other repos for php
yum groupinfo =
yum grouplist =
yum groupinstall XFCE = installs entire group XFCE
yum groupupdate XFCE = updates for group XFCE
yum list available = lists all packages available for installation
yum list extras – packages not installed from any repo
yum list installed = lists all installed softwares
yum list updates = updates available
yum list updates php = updates available for php
yum localinstall xyz.rpm = installs packages from the HDD or CD/DVD
yum update php/perl/etc = updates packages
yum install php/perl/etc = installs packages
yum install php* = installs all php packages
yum install hwbrowser =
yum install lshw =
yum list php* = lists all php packages
yum remove php = remove php
yum groupremove php = remove entire php group
yum search "php" =
yum whatprovides php =

CAL command for calendar

cal = shows calendar

cal 2009 = shows 2009 calendar

cal -j = prints current month's calendar where days are numbered

cal -m = pritns current month's calendar where Monday is the 1st day

cal -y = prints current year's calendar

cal 12 2005 = prints December month of 2005

GREP command

grep india /usr/share/dict/words = looks for the word 'india' in dictionary
grep “word” filename = prints lines with the “word ” in them
grep -n “word” filename = line numbers with the word in them printed
grep -vn “word” filename = lines without the “word” in them
grep -c “word” filename = total no. of occurrences of “word”
grep -n “word” * = lists all lines from all files that contain “word”
grep -x “word” * = only “word” a line
grep word filename = searchers for the word in the file
grep -i word filename = searchers for the word in the file
grep -i word1 word2 filename = searchers for the word in the file
groups = list of groups

SHUTDOWN command

shutdown -r = reboot

shutdown -0 (Zero) = reboot

shutdown – h = halt

LAST command

last = last log in details
lastlog [-u root] = last log in time
last [root] = entire log in history, the feature needs to be activated first
lastb [root] = prints failed login attempts

RPM command

rpm -e xyz = removes package xyz
rpm -e –nodeps xyz-5.6.fc5.i386 = removes 32+ bit version of package if more versions available
rpm -ivh xyz.rpm = install package xyz (i=install, v=verbose, h=hash)
rpm -ivh http://ftp.abc.com/xyz.rpm = install package xyz from the site
rpm -Uvh xyz.rpm = update package xyz (U=update)
rpm -q --scripts kernel |less = list of all preinstall & post-install scripts
rpm -q php = php version no.
rpm -qi php = php install info
rpm -qi fedora-release = Fedora installation info
rpm -qi php/per/python/ruby = version info for the package
rpm -qa grun = prints grub version no.
rpm -qa php = prints php version no.


rpm -qa | grep php = prints version nos. of all php related packages
rpm -qa | head = only 10 softwares listed
rpm -qa | head -n5 = first 5 software listed
rpm -qa | wc -l = total no of packages installed on the system
rpm -ql php = lists all files in a particular package
rpm -qal | grep php = find php in all installed packages
rpm -ql php | wc -l = total no. of files in a particular package
rpm -qa | grep php | wc -l = count the total number of php modules
rpm -qf /var/lib/php = what package a particular file belongs to
rpm -q --scripts mysql = scripts of a package
rpm -qa php | wc -l = total no. of php packages
rpm -qi php = info about php
rpm -q –last php = installation date of php
rpm -qi php | grep -i vendor = php vendor name
rpm -qi fedora-release | grep -i vendor = prints vendor name from a file named fedora-release
rpm -v = rpm version


rpm -qa --queryformat '%{NAME}==%{VENDOR}\n' | grep -v "Red Hat" | sort = list of installed packages with their vendor names except Red Hat
rpm -qa --qf '%{NAME}==%{VENDOR}\n' | grep "Red Hat" | sort = list of installed packages with their vendor name as Red Hat
rpm -qa --qf '%{NAME}==%{VENDOR}\n' | sort = list of installed packages with their vendor names
rpm -qa --qf '%{NAME}==%{VENDOR}\n' | grep "Red Hat" | wc -l = total number of installed packages with Red Hat as their vendor


rpm -qa --qf '%{NAME}==%{LICENSE}\n' | sort = list of all installed packages with their licence type sorted alphabetically
rpm -qa --qf '%{NAME}==%{LICENSE}\n' | wc -l = total number of installed packages with their licence type
rpm -qa --qf '%{NAME}==%{LICENSE}\n' | grep php | sort = list of all php packages with their licence types sorted alphabetically
rpm -qa --qf '%{NAME}==%{LICENSE}\n' | grep php | wc -l = total number of all php packages with their licence types



rpm -qa --qf '%{NAME}==%{SIZE}\n' | sort = list of all installed packages with their names and sizes in bytes sorted alphabetically
rpm -qa --qf '%{NAME}==%{SIZE}\n' | grep php | sort = list of all php packages with their names and sizes in bytes sorted alphabetically
rpm -qa --qf '%{NAME}==%{SIZE}\n' | grep php | wc -l = total number of installed php packages with their names and sizes in bytes



rpm -qa --qf '%{NAME}==%{SUMMARY}\n' | sort = list of all installed packages with their names and functions sorted alphabetically
rpm -qa --qf '%{NAME}==%{SUMMARY}\n' | grep php | sort = list of all php packages with their names and functions sorted alphabetically
rpm -qa --qf '%{NAME}==%{SUMMARY}\n' | grep php | wc -l = total number of all php packages with their names and functions


rpm -qa --qf '%{NAME}==%{BUILDHOST}\n' | sort = list of all installed packages with their names and buildhosts sorted alphabetically
rpm -qa --qf '%{NAME}==%{BUILDHOST}\n' | grep php | sort = list of all php packages with their names and buildhosts sorted alphabetically
rpm -qa --qf '%{NAME}==%{BUILDHOST}\n' | grep php | wc -l = total number of all php packages with their names and buildhosts


rpm -qa --qf '%{NAME}==%{URL}\n' | sort = list of all installed packages with their names and urls sorted alphabetically
rpm -qa --qf '%{NAME}==%{URL}\n' | grep php | sort = list of all php packages with their names and urls sorted alphabetically
rpm -qa --qf '%{NAME}==%{URL}\n' | grep php | wc -l = total number of all php packages with their names and urls


rpm -qa --qf '%{NAME}==%{ARCH}\n' | sort = list of all installed packages with their names and architecture type sorted alphabetically
rpm -qa --qf '%{NAME}==%{ARCH}\n' | grep php | sort = list of all php packages with their names and architecture type sorted alphabetically
rpm -qa --qf '%{NAME}==%{ARCH}\n' | grep php | wc -l = total number of all php packages with their names and architecture type



rpm –querytags = list of all rpm query tags
rpm –querytags | wc -l = total number of rpm tags
rpm -Va = verify all installed packages
rpm -Va | grep php = verify php packages only
rpm -Vv | grep php = check php packages only with verbose

FIND command

find -iname filename.ext = find a file by name
find . = lists all files and subdirectories in the current directory
find . -size +200M = finds files more than 200M in size
find . -size +200M -ls = more details
find . -name *.txt -size +40K = finds .txt file names of more than 40 k in size
find /usr/share/docs | xargs grep -l 'keyword' = finds files that contain the keyword from documents
finger = log in details

UNAME command

uname = operating system name

uname -r = Linux version

uname -o = operating system name

uname -m = system architecture

uname -n = host name

uname -p = processor architecture

uname -s = os name

uname -v = Linux update time

uname –hardware-platform