These lab sessions are created for NCSI-IDRC Workshop on Integrated Library
Automation Packages: July 27th to 31st, 2009
1.1. Lab session: Basic LINUX commands
Files
Following are the basic commands which deal with files in Linux
Operating system
ls --- lists your files
ls -l --- lists your files in 'long format', which contains lots of useful information,
e.g. the exact size of the file, who owns the file and who has the right to look at it,
and when it was last modified.
ls -a --- lists all files, including the ones whose filenames begin in a dot, which
you do not always want to see.
mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it
into a different directory (see below)
cp filename1 filename2 --- copies a file
rm filename --- removes a file. It is wise to use the option rm –i
diff filename1 filename2 --- compares files, and shows where they differ
wc filename --- tells you how many lines, words, and characters there are in a file
chmod options filename --- lets you change the read, write, and execute
permissions on your files.
File Compression
o gzip filename --- compresses files, so that they take up much less space.
Usually text files compress to about half their original size, but it depends
very much on the size of the file and the nature of the contents. There are
other tools for this purpose, too (e.g. compress), but gzip usually gives the
highest compression rate. Gzip produces files with the ending '.gz'
appended to the original filename.
o gunzip filename --- uncompresses files compressed by gzip.
o gzcat filename --- lets you look at a gzipped file without actually having to
gunzip it (same as gunzip -c). You can even print it directly, using gzcat
filename | lpr
o tar
Directories
Directories, like folders on a Macintosh, are used to group files together in a hierarchical
structure.
mkdir dirname --- make a new directory
cd dirname --- change directory.
pwd --- tells you where you currently are.
©2009 National center for science Information. Indian Institute of Science. Bengalore – 560 012, India.
Lab session: Basic LINUX commands
File Management
emacs : `Using the emacs text editor'
mkdir : `Creating a directory'
cd : `Changing your current working directory'
ls : `Finding out what files you have'
cp : `Making a copy of a file'
mv : `Changing the name of a file'
rm : `Getting rid of unwanted files'
chmod : `Controlling access to your files'
cmp : Comparing two files
wc : Word, line, and character count
compress : Compress a file
Communication
e-mail : `Sending and receiving electronic mail' ; talk : Talk to another user
write : Write messages to another user; sftp : Secure file transfer protocol
File download
http:// , ftp: , wget:, apt-get , aptitude, dpkg, Through synaptic manager.
Information
man : Manual pages
quota –v : Finding out your available disk space quota
ical : `Using the Ical personal organizer'
finger : Getting information about a user
passwd: Changing your password
who : Finding out who's logged on
Printing
lpr : `Printing' ; lprm : Removing a print job ; lpq: Checking the print queues
Job control
ps : `Finding your processes'
kill : `Killing a process'
nohup : Continuing a job after logout
nice : Changing the priority of a job
& : `What is a background process?'
Cntrl-z : Suspending a process
fg : `Resuming a suspended process'
©2009 National center for science Information. Indian Institute of Science. Bengalore – 560 012, India. 2