1.1.basic Linux Command
1.1.basic Linux Command
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.
©2009 National center for science Information. Indian Institute of Science. Bengalore – 560 012, India.
Lab session: Basic LINUX commands
File Management
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
Information
Printing
lpr : `Printing' ; lprm : Removing a print job ; lpq: Checking the print queues
Job control
©2009 National center for science Information. Indian Institute of Science. Bengalore – 560 012, India. 2