by Sandeep Desai (http://www.thedesai.net)
I have installed
Fedora Red Hat Linux, so this document is Red Hat centric but 90% of the
information should apply to other Linux distributions and around 70% to Unix. This
document is meant to be a quick reference for Linux/Unix information.
Running Linux by Matt Welsh 4th Ed (O’Reilly)
UNIX in a Nutshell by Robbins (O’Reilly)
Unlike Microsoft
Windows, you can view every part of the Linux as it is open source and it is
very modular. You can look at every part of Linux e.g. the scripts that are
used for booting. You can endlessly tinker with it. Also Linux is very modular,
so you can startup a barebones with no Window Manager or with everything..
The kernel is the
core part of Linux, which provides basic services such as running a program,
accessing the hard disk, managing the hardware. The X-Windows is a layer which
provides basic graphics services. The Window manager provides services such as
moving, resizing the windows etc e.g. fvmw and kwin from KDE. The Desktop
environment like KDE or GNOME provide a set of grapical applications to work
with Linux.
X-Window consists
of a server and a client, which can be both run on different machines. The
first xclock is displayed on foohost1 and the second on foohost2. Note that you
need to have an X-Windows server running on foohost1 and foohost2
rlogin –l
foohost1
xclock &
setenv DISPLAY
foohost2 :0.0
xclock&
LAMP is a very
popular web development system.
Typical steps are
$./configure
$make
$make install
Intrusions
Linux supports TCP/IP protocol. Every machine has a unique 128 bit address
(IP address) expressed typically as 4 numbers e.g 111.222.333.444. 111.222 is the network part, 333 is the
subnet and 444 is the host identifier.
A DNS (Domain Name Server) provides a name to IP address lookup.
Network configuration
Optionally you can use DHCP (Dynamic Host Configuration Protocol) to request an IP address
Networking protocols
Protocol |
Port |
http |
80 |
ftp |
|
telnet |
|
ssh |
|
rsh |
|
NIS (aka Yellow Pages) allows you to centrally manage accounts like Windows Domain Server. NIS has servers, slaves (copy of server NIS database) and client
NFS (Network File Server) allows you to mount a remote directory locally, does not do encryption.
cat >> /etc/fstab
foohost:/usr /foo/bar NFS defaults
Ctrl-D
foohost should export /usr by adding it to /etc/exports
tcpd is a wrapper which can be used to deny
or allow access to certain hosts e.g can be used as a wrapper for fingerd.
xinetd implements a TCP/IP wrapper around inetd. The TCP/IP wrapper checks
/etc/hosts.allow and /etc/hosts.deny files before allowing a conneciton.
kde packages, kdegraphics, kdeutils, kdenetwork, kdeadmin, koffice,
kde konquerer (web browser) can do man :ls info :ls gg :linux // search google for linux
export PATH=/opt/kde3/bin :$PATH
export LD_LIBRARY_PATH=/opt/kde3/lib
exec startkde
Kdevelop an IDE for C
Has Nautilus File Manager
Desktop folder in ~/.gnome-desktop
gphoto
ximian email etc
.fvwm2rc or .fvwm or
/usr/lib/X11/fvwm2/system.fvwmrc
X-Windows
On startup runs commands in users home directory .xinitrc or /usr/X11R6/lib/X11/xinit/xinitrc
Ctrl Alt – and Ctl Alt + to change
resolution
Windows toolkit
Motif (outdated)
Qt is a C++ GUI toolkit used by KDE
GTK C GUI toolkit orginally developed for GIMP
Web site |
|
Free Books |
|
www.debian.org |
Debian Linux
Distribution |
Linux/Unix
utilities |
|
Gnu Open Source
projects |
|
Linux Kernel |
|
Free online
Linux magazine |
|
Linux journal
magzine |
|
Linux Magazine |
|
Linux Today |
|
Linux Weekly
web news |
|
www.newsforge.com |
|
www.redhat.com |
Red Hat Linux
has two distributions, Red Hat Enterprise Linux and Fedora Linux for
consumers |
Red Hat
Distribution with latest Linux stuff |
|
|
|
Open Source
Projects with documentation and code |
|
The Linux
Documentation Project |
|
Windows
Emulator (Run Windows applications) |
|
www.winimage.com/bootpart.htm |
Add Partitions
to Windows Boot Loader (c:\boot.ini) |
linux-ntfs.sourceforge.net |
Read Windows
NTFS from Linux |
www.symantec.com |
Symantec
Partition Magic (Formely Powerquest) |
database of
packages/applications available |
|
|
|
comp.os.linux.announce |
|
Linux tutorial
for new users |
|
linux.about.com/library/cmd/blcmdl.htm |
Linux command
Reference and other linux info |
Download 1/i386/iso/yarrow-i386*.iso CD images (don’t download the SRPMS). Use Roxio for Windows to create a CD from the .iso file.
Change your PC BIOS boot sequence to boot from the CD first.
lilo is Linux boot loader (/etc/lilo.conf)
grub is Linux boot loader (/etc/grub.conf)
You can use Partition Magic to resize your partitions without formating
your data
If you overwrite the Windows XP Boot Loader with Grub or Lilo and your
machine won’t boot. You can fix this by booting with your Windows XP CD,
running the recovery console and running the fixmbr program. Windows stores the
list of OS to run form in c:\boot.ini. You should use Grub or Lilo instead of
the Windows Boot Loader.
Useful for pattern matching
^foo ?[0-9]ab*\ ? will
match fooz4abcd ?
^ is first character
$ is last character
* any sequence
[x-y] range
? match any one character
\ escape to match one of the regular expression characters like ?
See http://www.oreillynet.com/linux/cmd/
Some of the commands listed here should be run as root and will be found in
the /sbin directory
Command |
Description/Examples |
adduser |
add a user // Run as root copies files from /etc/skel such as .shrc |
apropos |
find man pages which match apropos format // man pages with format word |
ar |
Build library archive gcc –o foo.c ar rs libfoo.a foo.o (see gcc) |
automount |
automount file system. There will be one automount process per automount ps aux | grep automount |
bison |
GNU version of yacc, Generates parsers based on input grammar |
bunzip |
|
bzip |
Newer than gzip, compresses 10-20% more |
calls |
calls foo.c // show function-call tree |
cat |
list contents of file |
chmod |
File permissions chmod +rwx foo chmod 777 foo |
chown |
change file owner |
chsh ypchsh |
change shell |
compress |
Old Unix programs to compress files |
crontab |
schedule tasks crontab hour minute day month dayofweek command crontab 0 2 15 * sun rm /foo.txt crontab –e // edit all entries crontab –l // list all entries crontab –u foo –e // run as root to edit crontab entries for user foo |
cvs |
Concurrent Version system, works with full directory trees, user works on a local copy of a project and then submits all the changes. setenv CVSROOT=/project/foo // CVS repository cvs init // create repository cvs import /somedir foocompnay footage cvs mkdir foo cvs checkout $CVSROOT/modules vi $CVSROOT/modules cvs checkout foodir cvs commit foo.c // checkin all the changes cvs commit cvs update // refresh local copy from repository should be done before a commit cvs release // we are done cvs is used for most open source projects and can be used over the network set CVS-RSH=ssh // default is rsh cvs –d ext:user@foodomain.com:/path/to/repository checkout foodir // work on a cvs session cvs –d :pserver:users@foodomain.com:/path/to/repository login |
date |
date 0101010004 This would set the date to January 1 (0101), 1 a.m. (0100), 2004. Require superuser privilege date +"%H %M %S" date -d '2 day' // todays date + 2 days date -d '-2 day' // todays date - 2 days |
dd |
create or copy file dd if=/dev/zero of=/test count=32768 |
df |
disk free df -h |
dhclient |
request a new IP address using DHCP (dhcpd daemon) |
diff |
difference between two files diff –c foo.old foo.new > foo.patch patch –verbose < foo.patch // will update foo.old with changes from foo.new diff –cr foo.old foo.new > foo.patch // r is recursive patch –p) < foo.patch |
dos2unix |
see unix2dos |
dmesg |
Show kernel log |
du |
Disk Usage du -h // human readable output du --max_depth=2 . du -x
--block-size=1024K | sort -nr | head –15 // show 15 largest files see df for disk free |
dumpe2fs |
dumpe2fs /dev/hda3 // loads of info about file system |
fdformat |
format floppy disk (superformat on debian) |
fdisk |
Partition hard disk /sbin/fdisk (see parted) fdisk -l |
flex |
Lexical analyzer code generator, used for creating language interpreters or compliers Generates C Code (see lex, bison, yacc) |
fsck e2fsck |
file system check fsck –t ext2 /dev/hda2 /dev/hda is entire hard diks /dev/hda2 is 2nd partition do an unmount before doing a fsck ext2fs has a superblock which has important information about the file system, if this is corrupted, user cannot mount the file system. The superblock is backed up at every 8192+1 block, to recover run e2fsck –f –b 8193 |
free |
shows memory usage and memory free in kilobytes |
g++ |
Gnu C++ compiler, has same options has gcc |
gcc |
Gnu C Compiler gcc –v // version front end to /usr/lib/gcc-lib/machine/version e.g. /usr/lib/gcc-lib/i386-redhat-linux/3.2.3 gcc –o hello hello.c // if –o not used then executable file name is a.out gcc -c hello.c // produce object file, do not link gcc –g hello.c // -g is debug gcc –I../include –L ../lib –o a.c –lfoo // use libfoo.a library by default look in /usr/lib gcc –shared –o libfoo.so // create a shared library gcc –pg foo.c foo // put profiling information foo gprof foo gman.out (see ar, ld, calls) |
gdb |
GNU Debugger for C and C++ $gcc –g foo.c –o foo $gdb foo > list // show code > break 19 // breakpoint at line 19 >break foo.c:19 // breakpoint in foo.c at line 19 >run arg1 arg2 // run program with arguments >next // step over >step // step into >until 27 // run until line 27 >print var1 // print contents for var1 variable >backtrace // dump stack >quit $foo Segmentation fault $gdb foo core // run in bash ulimit –c unlimited to create core files >quit $gdb foo 123 // attach to process with pid 123 > continue >print var1=3 // assignment >ptype var1 // details of var1’s type >x/s var1 // dump memory of var1 as string >info // where we are >info locals // local variables >nexti // debug assembly >stepi |
gprof |
C Program Profiler, show in which functions program is spending the most time, used for optimizing C Programs $gcc –pg foo.c foo // put profiling information $foo $gprof foo gman |
grep |
grep text in file e.g. grep abcd *.java |
groups |
Which groups currently logged in user belongs to |
gs |
Ghostscript, A postscript file viewer. |
gunzip |
gunzip –c foo.txt.gz // equivalent to cat |
gzip |
Compress files gzip foo.txt // create foo.txt.gz gzip-l foo.txt.gz gunzip foo.txt.gz // uncompress file user tar to store multiple files into one .tar file (see compress and bzip) |
hostname |
show or set hostname, set in /etc/rc.d/rc.sysinit |
ifconfig |
Configure Network Interface, set host IP address, subnet mask etc (see route) /sbin/ifconfig eth0 // show network configuration info |
inetd |
Daemon which listens on many ports and starts a network server process such as ftpd or telnetd on request (see xinetd) /etc/inetd.conf or /etc/xinetd.conf |
info |
GNU documentation, maybe more detailed and up to date then man info ls (see man) |
init |
Run at boot time init 2 // Run all runlevel process from 1 to 2 |
insmod |
add kernel loadable module to next boot |
ipcs |
Details on Inter Process Communications such as shared memory, semaphores, messages –l option returns limits |
ipfilter |
IP Packet filtering for security |
kill |
kill process kill –TERM 1234 // kill process 1234, See ps to get process details or
see /proc directory |
killall |
kill process by name killall –TERM smbd nmbd |
laptop_mode |
/proc/sys/vm/laptop_mode turn on laptop mode |
last |
when user last logged in reads from /var/log/wtmp |
ldconfig |
/sbin/lconfig clears shared library cache, run after updating a shared library |
ld |
Link object files with libraries to create executable (see gcc) |
ldd |
ldd foo // lists libraries used by application ldd /usr/bin/X11/xterm see /etc/ld.so.conf see ldconfig when updating libraries .so libraries are loaded from /usr /usr/lib /etc/ld.so.conf and
LD_LIBRARY_PATH environment variable |
less |
less foo.txt // page wise listing of text file can do page up and page
down (see more) |
lex |
See flex |
locate |
locate indexed files |
lpr |
lpr foo // spool file for printing, printed by lpd daemon |
ls |
List directories ls –l // list all files -rwxrw-r—1 sdesai admin 1234 May 1 12 :00 a.txt |
lsmod |
/sbin/lsmod, list kernel loadable modules see insmod to add module |
lspci |
/sbin/lspci show PCI devices |
make |
Setup rules to build programs OBJECTS=a.o b.o # run shell command to get host name HOST_NAME=$(shell uname –n) # make sure you use tabs #each shell command is run in a different shell, so use ; to do it in one shell target: cd obj;rm * all: $(OBJECTS) gcc –o foo a.o b.o # rules can be set to build all *.o from *.c so that each individual file is not specified # $< is the *.c file %.o: %.c gcc –c –o $@ $< (see automake and autoconf for generating make files) |
man |
documenation of commands (See info command) man ls appropos edit // find all man pages with edit in the command if man does not work set $MANPATH properly |
mkfs |
make filesystem mkfs –t msdod /dev/fd0 fdformat /dev/fd0 (superformat on debian) |
mknod |
mknod /dev/foo b 6 13 create a block device with major number 6 and minor number 13 |
mkswap |
Setup swap on file or device dd if=/dev/zero of = /swapfile bs=1024 count=32768 mkswap –c /swapfile 32768 chmod 0600 /swapfile swapon /swapfile swapoff /swapfile |
modprobe |
load kernel module |
more |
page wise list of text file cat foo.txt | more (see less) |
mount |
mount –t ext2 /dev/hda2 /mnt mount –t vfat /dev/hda3 (Mount Winodws 95/98 VFAT and FAT32 Partition) -ro switch mounts read only mount –a mounts all files in /etc/fstab |
netstat |
TCP/IP ports open (Works on windows) netstat –p // which daemons are listening on which ports netstat -f inet -a | grep LISTEN netstat –rn // show routing table |
newgrp |
assume group id (should be logged in) newgrp 7 // assume group id 7 |
parted |
Partition Editor (See fdisk) /sbin/parted |
passwd |
change passwd, password stored in /etc/passwd or /etc/shadow |
patch |
patch changes from a new file to an old file diff –c foo.old foo.new > foo.patch patch –verbose < foo.patch // will update foo.old with changes from foo.new patch –R < foo.path // undo patch changes |
ps |
process Status ps –ef ps ax // all process ps –C httpd // httpd* processes See /proc directory |
pstree |
show list of process as tree, this will show the parent child relationship of processes |
rdev |
Change root mapping and etc rdev / /dev/hda3 |
rpm |
Linux package manager used by Red Hat for installing/deinstalling software packages like mysql etc run as root rpm –e foobar // remove package rpm –q foobar // query package status rpm –ivh foobar // install foobar rpm –Uvh foobar // upgrade rpm –qa // list packages rpm –qf /usr/bin/foo // which package file foo belongs to rpm –ql foo // list files installed by the foo package |
sed |
cf=`echo $1 | sed 's/hello/world/g'` replace hello with world |
setterm |
terminal settings setterm –foreground white –background black setterm –store // save settings |
swapon |
Add Swap space to Linux swapon –a is run at boot-time from /etc/rc.d/rc.sysinit to add all swap from /etc/fstab |
rlogin |
|
route |
/sbin/route add [-net | host] destination [gw gateway] [metric metric] options /sbin/route add default gw 1.2.3.4 metric 1
metric is for multiple routes, first try routes with lower metric number typically set in /etc/rc.d/rc.inet2 while booting |
rsh hostname –l username –n command |
password and userid on client and server machine should be same. Also /etc/hosts.equiv should have have hostname for machine from which rsh is being run. e.g rsh sbdesai-sun –l sbdesai –n ls |
shutdown |
shutdown –r now |
sort |
sort -m foo1 foo2 // merge files sort foo // sort files see uniq to remove duplicate lines |
startx |
Start X Windows server, runs commands in users home directories .xinitrc or /usr/X11R6/lib/X11/xinit/xinitrc |
strace |
show system calls being made by program useful to check if a long running program is still running strace foo strace –p 123 // system calls being made by a running process |
stty |
terminal settings stty –a // terminal settings stty erase ^H // use backspace for deleting stty quit ^X |
su |
switch user, login as another user su – foo // login as foo and run shell files such as .shrc etc su – root |
superformat |
format floppy disk in Debian (see fdformat for Red Hat) |
telnet |
|
tail –f filename |
show bottom of file and keep displaying as file is updated (Good for viewing log files) |
tar |
create file archive of multiple files tar cvf foo.tar /etc /usr // create tar file tar xvf foo.tar // extract file tar tvf foo.tar // list contents tar cvzf foo.tar.gz /etc // gzip compressed tar ls –l foo.lst tar –cv –T foo.lst –f foo.tar // read foo.lst to for list of files to tar // script to make a copy of a directory cd source tar cf - . | (cd ../dest; tar xvf -) |
touch |
touch foo update to current date/time stamp for file |
umask |
File permissions to use when creating new files |
uname |
Print System name e.g output on Solaris is ‘SunOS’ uname –a // which kernel version etc uname -s // which Operating System uname -n // host name |
uncompress |
|
unmount |
unmount /dev/hda3 unmount /mnt // unmount device of mount directory |
uniq |
Remove duplicate lines sort foo | uniq |
unix2dos |
see dos2unix |
useradd |
/sbin/useradd to add user |
userdel |
userdel –r foo //remove user foo, run as root |
vi |
Visual editor (vi cheat sheet) |
vim |
enhanched vi editor vim –g // launch GUI |
xargs |
add args to each line in input e.g find . –print | xargs cat |
xclock |
starts X-Windows clock |
xfontsel |
View Fonts in an X-Window |
xhost |
Allows access to show X-Windows remotely xhost + |
xinetd |
see inetd (Networking daemon) |
xload |
Show X-Windows system load average for X Display |
xlsfonts |
list fonts (command line) |
xrdb |
X Resources Database xrdb –load $HOME/.Xpreferences |
xterm |
start X-Windows terminal |
valgrind |
KDE Valgrind is a memory debugger at valgrind.kde.org gcc –g foo.c –o foo valgrind foo // will show invalid memory access as program runs valgrind –leak-check=yes –show-reachable=yes foo |
yacc |
Parser Generator (see bison) |
ypwhich |
query NIS database |
w |
who is logged in (see /var/log/utmp) |
wc |
word count e.g. wc –l for lines |
which |
show path for executable by searching $PATH |
who am i |
current user logged in |
User commands
diff, patch
C Programming tools
gcc, calls, ar, ld, ldd, gdb, flex, bison, strace, valgrind (KDE)
diff, patch
RCS (Revision Control System)
ci foo.c
co –l foo.c
co –l1.1 foo.c
CVS (Concurrent Version System)
Consists of a central repository, developer make a local copy like a sandbox and modifies files locally, All changes are submitted to the repository. If another user has made a change to the file then we need to refresh our view and then checkin the files.
Shell/Script programming tools
perl, awk, sed, find, xargs
Kernel
System administration
adduser, strace (useful to check if a long running program is still running)
Networking
rsh, rexec, ssh, sshd, ping, telnet, rlogin, named, routed (obtain routing information) dhclient (DHCP Client) tcpd (TCP/IP Wrapper)
X-Windows
xterm
Daemons
xinetd (inetd), syslogd, routed, named
Unix Files & directories
/etc/exports |
List directories which can be shared using NFS cat >> /etc/fstab foohost:/usr /foo/bar NFS defaults Ctrl-D
foohost should export /usr by adding it to /etc/exports |
/etc/fstab |
device mount-point type options e.g. /dev/hda3 / ext3 |
|
|
/etc/group |
List of groups groupname:passwd:gid:members |
/etc/host.conf |
how to resolve hostname to IP address order hosts,bind # first try /etc/hosts then DNS Server |
/etc/hosts |
hostname to IP address mapping, if DNS is setup properly this file should be almost empty localhost 127.0.0.1 # default entry foohost 12.34.56.78 (see ifconfig) |
/etc/hosts.allow |
list of hosts for which the xinetd or the tcpd should allow connections from |
/etc/hosts.deny |
list of hosts for which the xinetd or the tcpd should deny connections from |
/etc/hosts.equiv |
List of machines from which to allow remote connections for rsh/rcp/rlogin etc |
/etc/inetd.conf /etc/xinetd.conf |
List of daemon to start on connection request e.g start ftp server on ftp request. |
/etc/init.d |
list of services to run |
/etc/inittab |
Details of process to run while booting Process startup order is determined by the runlevel |
/etc/ld.so.conf |
list of directories where to search for shared object libraries .so are searched in /usr /usr/lib etc/ld.so.conf LD_LIBRARY_PATH see ldd and ldconfig |
/etc/modules.conf |
list of kernel loadable modules, see lsmod, insmod, modprobe |
/etc/networks |
used by route/routed |
/etc/passwd |
List of OS userids username:passwd:uid:gid:gecos:homedir:shell uid is unique userid (root is 0) gid is group id gecos is info like name |
/etc/resolv.conf |
list of DNS Servers search foo.net foo.com # which to domain to search in |
/etc/services |
list of network services and the port number that they use |
/etc/sysconfig/iptables |
iptables rules for IP packet filtering (see iptables) |
/etc/sysctl.conf |
Kernel settings such as shared memory etc |
/etc/syslog.conf |
syslogd configuration settings, where various log messages are sent e.g kernel log messages. Make configuration changes kill –HUP `cat /var/run/syslog.pid` and restart syslogd daemon for changes to take effect |
/etc/X11/XF86Config |
keyboard, mouse, Video Card and monitor configuration information (see startx) |
/etc/yp.conf |
NIS lookup info |
/proc |
Process information |
/sbin |
kernel and root level applications |
/usr/src/linux |
Linux sources maybe in /usr/src/kernel-source-vesion-number |
/usr/lib/X11/rgb.txt |
Color to name mapping can be used in X-Windows apps e.g xclock –fg black –bg white // The black and white are defined in the rgb.txt file |
/usr/lib/X11/fvwm2/system.fvwmrc |
|
/var/log/utmp |
binary file, who is currently logged in (see w, finger, who) |
/var/log/wtmp |
binary file, when user last logged in (see last) |
|
|
Files in users home directory
.fvwm |
FVWM Windows Manager configuration file |
|
|
|
|
|
|
|
|
ext2 |
Most common, 256 character filenames, 32TB max size. Superblock stores important information, if corrupted (will be reported as mount failure) run e2fsck –f –b 8193 to restore from backup at block 8192+1 |
ext3 |
|
ramfs |
RAM |
cramfs |
compressed RAM |
msdos |
MSDOS FAT |
swap |
Virtual Memory used by Unix, can have 8 partitions or files of 2GB each for total of 16GB on x86 (See mkswap) |
vfat |
Windows 95/96 FAT32 |
ntfs |
Windows NT/2000/XP NTFS |
proc |
virtual filesystem for process information |
devfs |
/dev |
iso9600 |
CD-ROM (High Sierra) |
udf |
CD-RW and DVD |
smbfs |
Access Windows Server |
· init process is started which starts processes listed in /etc/inittab
· inetd is daemon which listens for requests and then starts process listed in /etc/inted.conf e.g ftpd is only started when an ftp request is made this way we do not have large number of daemons listening for requests
· kernel messages are written to /var/log/messages (dmesg shows messages)
· /etc/init.d/autofs will automount from /etc/fstab (see /etc/auto.master)
shutdown –r now
Devices are in /dev directory they are either block devices or character devices. A device has a major number and a minor number. The major number indicates type of device and minor number is a unique number for different devices of the same type. See mknod
ls –l /dev
brw------- 1 root root disk 3, 0 Apr 1, 2004 foodev
/dev/camera |
|
/dev/fd* |
floppy disk |
/dev/hda |
First Hard disk |
/dev/hda1 |
First Hard disk Partition 1 |
/dev/tty* |
terminals |
/dev/cdrom |
CD-ROM/DVD-ROM drive |
/dev/mem |
Memory |
/dev/null |
cat /dev/null > foo.log to clear a file |
/dev/usb |
|
// ftp://ftp.ibiblio.org/pub/linux
cp foo.so.6.4 /lib
cp foo.a /usr/lib
cd /usr/lib
ln –sf foo.so.6.4 foo.so.6
rm foo.so.6.3
/sbin/ldconfig
// find files changed in the last 24 hours
find / -mtime –1 \! –type d –print
Has two mode, edit and command mode, to type in text pres i, to go into command mode press Esc
To save Esc-:x
Esc:set nu |
Show linenumbers |
a |
append |
i |
Insert text |
1,$s/search_string/repalcement_string/g |
Search and repalce globally from 1 to last line |
<Control> B |
Move backward one screen |
<Control> f |
Move Forward one screen |
<Control> d |
move half a screen down |
<Control> u |
move half a screen up |
G |
move to end of file |
65G |
move to 65th line in the file |
0 |
move to begining of line |
/mysearch |
forward search for string ‘mysearch’ |
?mysearch |
backward search for string ‘mysearch’ |
n |
Next occurence of mysearch in the search direction |
N |
next occurence of mysearch in the opposite direction |
R |
Replace |
u |
undo command |
x |
delete character |
ex mode press Esc :
r foo.txt |
read file into edit buffer |
r !ls -l |
contents of ls –l in edit buffer |
[x,y]s/pattern/replace/options |
s/foo/foo2/g search foo with foo2 globally 1,10s/foo/foo2/g |
|
|
|
|
registers a-z
ayy save to register a
ap paste from register a
When a user logins, they are working in a shell as defined in /etc/passwd. The popular shells are
Globbing is where the shell replaces a pattern like *.pl with all the files that match
$cat *.pl # becomes cat a.pl b.pl c.pl
$ echo $SHELL
$cat > xyz
[1] 1234
$jobs
1 cat > xyz
$fg 1 // bring job 1 to foreground
Ctrl-Z suspend process
Ctrl-S suspend terminal
Ctrl-Q resume terminal
Ctrl-
tcsh and bash support command line editing
export VISUAL=vi
export VISUAL=emacs
noclobber=1
set noclobber // do not overwrite files
cat .cshrc
alias foo cat foo
export path = ($PATH /usr/bin)
.login is executed first time user logs in
.cshrc is executed every time csh is run
Set var=value Set’s var environment variable
Source xyz.csh Runs script in current shell (so environment variables will be set in current shell)
.profile is launched first time ksh is run
.shrc script is run on every invocation of ksh
. xyz.ksh (Runs the script in the current shell instead of launching a shell and running in it)
if test $1 == $2
then echo “match”
else echo “nomatch”
fi
Bourne Again Shell (bash)
cat .bashrc
tarc () {tar cvf $1.tar $1 }
Linux Software
|
www.apache.org |
|
|
|
|
|
|
|
www.gnome.org |
|
www.x.org
|
|
www.blackdown.org |
|
www.kde.org |
|
|
|
www.mozilla.org |
|
www.mysql.org |
|
www.openoffice .org (like Microsoft
Office) |
|
www.perl.org |
|
www.php.net |
|
|
|
|
|
www.samba.org |
|
|
|
|
|
www.xfree86.org |
|
|
|
|
|
|
prtconf |
Print System Configuration prtconf | grep Mem |
showrev –p |
shows list of patches installed |
truss |
print list of system calls a process is making, useful for finding out if a process has hung e.g truss –p –v all 1234 (1234 is process id) |
|
|
CDROM is accessible as /cdrom. To eject do cd /cdrom; eject
On Solaris, you can use the rdate
command (As root) to set your system's time against a remote server:
rdate olapvob3.us.oracle.com
To get this to happen regularly, as
root run crontab -e
crond is the daemon that runs commands periodically. Add a line that
looks like
0 * * * * rdate olapvob3.us.oracle.com > /dev/null 2>&1
if there isn't one already. This will cause your system to set its time
against olapvob3 every hour.
Installed in /usr/sbin/httpd or /etc/apache (on debian)
start by running /etc/init.d/httpd <start|stop|restart>
httpd –f /etc/httpd/httpd.conf
httpd -l
/etc/httpd directory contains configuration files
/var/log/httpd contains log file information
httpd.conf is the configuration file
httpd.conf
DocumentRoot |
Directory from which HTML documents should be displayed |
LoadModule |
Apache dynamically loaded extension modules e.g Perl Module |
ScriptAlias |
/cgi-bin/ /foo/cgi-bin # location of CGI scripts |
ServerRoot |
where configuration files are (default /etc/httpd) |
ServerType |
run as inetd or daemon |
Listen |
Port to listen on, below 1024 requires root access default is 80 |
DirectoryIndex |
file to show when only url entered (default should be index.html) |
<Directory “/foo/bar”> order allow,deny </Directory> |
|
access.conf
.htaccess located in each directory which lists permissions for file access
/usr/bin or /usr/local/bin or /etc/init.d/mysql
mysql // start server
scripts/mysql_install_db
mysqladmin version
mysql –u root
Ø show databases
Ø set password for root=password(‘newpassword’);
Ø flush privileges
Ø create database foo
Ø use database foo
Ø show tables
Scripting language like Microsoft ASP (Active Server Pages) and Java Server Pages that allows you to mix HTML and the PHP scripting language to develop web applications
<?php
phpinfo();
?>
Samba
(Access Unix directories from Windows as a Windows share)
Samba supports Microsoft SMB (Server Message Block) aka Common Internet File System protocol.
Install samba from www.samba.org
download samba*.Z to samba directory
gunzip samba*.Z
tar xvf samba*.tar
cd source
./configure
make
make install
cd ../packaging/Solaris
mkpkg.sh
cd /tmp
su root
pkgadd –D . samba (Solaris)
su root
// older version
pkgadd –d . SAMBAroot (Solaris)
pkgadd –d. SAMBAusr (Solaris)
To restart samba (file maybe called samba.server or smb)
/etc/init.d/samba stop
/etc/init.d/samba start
/usr/local/samba/bin/smbd –D
/usr/local/samba/bin/nmbd –D
To stop run killall –TERM smbd nmbd
smbmount //foohost/c_drive /test –o fooname/foodomain // may have to run as root
smbmount //foohost/c_drive /test –o credentials=/etc/foo // foo contains userid passwd
smbclient allows you to browse a Windows share (like a ftp)
>ls
>quit
Use dos2unix, unix2dos to convert ascii files, windows user \r\n (Carraige return-Line Feed) to terminate line, Unix use \n
Messages logged to /var/log/samba
smbpasswd to manager user/passwd
smbpasswd –a username // so that we donot have to enter passwords for smbmount
shares are listed in /usr/local/samba/lib/smb.conf or /opt/samba/lib/smb.conf or /etc/samba/samba.conf file listed below is a sample smb.conf file
Run testparm to check that samba configuration file is OK
# applies to all
[global]
guest account = sbdesai
# share all users home directories
[homes]
# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
workgroup = WALT-DCNT
# server string is the equivalent of the NT Description field
server string =
# Security mode. Most people will want user level security. See
# security_level.txt for details.
security = share
# Use password server option only with security = server
; password server = WALT-DCNT-PDC
# Most people will find that this option gives better performance.
# See speed.txt and the manual pages for details
socket options = TCP_NODELAY
# Browser Control Options:
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
local master = no
# Use only if you have an NT server on your network that has been
# configured at install time to be a primary domain controller.
domain controller = WALT-DCNT-PDC
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The built-in default for versions 1.9.17 is yes,
# this has been changed in version 1.9.18 to no.
dns proxy = no
#============================ Share Definitions ==============================
[ade]
comment =
path = /ade
public = yes
writable = yes
hosts allow = 138.1.196.199 138.1.196.200 138.1.196.240
[emdw]
comment =
path = /users/sbdesai/.ade/view_storage/sbdesai_emdw_main2/emdw
public = yes
writable = yes
hosts allow = 138.1.196.199 138.1.196.200 138.1.196.240