Professional Documents
Culture Documents
Command Memento
Command Memento
diff r dir1 dir2
tar jtvf archive.tar.bz2 Access the full manual page of a command:
man grep
Concatenate and display file contents: Extract the contents of a compressed archive:
Summary of most useful commands cat file1 file2 Looking for files tar zxvf archive.tar.gz
Misc commands
tar jxvf archive.tar.bz2
©Copyright 2006-2005, Free Electrons. Display the contents of several files (stopping Find all files in the current (.) directory and its Basic command-line calculator
Free to share under the terms of the Creative Commons at each page): subdirectories with log in their name: tar options: bc l
Attribution-ShareAlike 2.5 license more file1 file2 find . name “*log*” c: create
(http://creativecommons.org) less file1 file2 (better: extra features) t: test Basic system administration
Find all the .pdf files in dir and subdirectories x: extract
Sources, translations, updates, command and concepts Display the first 10 lines of a file: Change the owner and group of a directory and
details on our free training materials:
and run a command on each: j: on the fly bzip2 (un)compression
head 10 file find . name “*.pdf” exec xpdf {} ';' all its contents:
http://free-electrons.com/training/intro_unix_linux z: on the fly gzip (un)compression
chown R newuser:newgroup dir
Display the last 10 lines of a file: Quick system-wide file search by pattern
Thanks to Michel Blanc, Hermann J. Beckers and Thierry tail 10 file Using 7-zip: (better compression than bzip2!)
(caution: index based, misses new files): Reboot the machine in 5 minutes:
Grellier. 7z a archive.7z <files> (add: create)
locate “*pub*” shutdown r +5
7z l archive.7z (list)
Latest update: Jun 8, 2007 File name pattern matching 7z x archive.7z (extract) Shutdown the machine now:
Concatenate all “regular” files: Redirecting command output shutdown h now
Handling files and directories cat * Redirect command output to a file:
7-zip compressed tar archive
(keeps user and group information) Display all available network interfaces:
Create a directory: Concatenate all “hidden” files: ls *.png > image_files
tar cf dir | 7z a si dir.tar.7z (create) ifconfig a
mkdir dir cat .* Append command output to an existing file: 7z x so dir.tar.7z | tar xf (extract)
Assign an IP address to a network interface:
Create nested directories: Concatenate all files ending with .log: ls *.jpg >> image_files
Handling zip archives ifconfig eth0 207.46.130.108
mkdir p dir1/dir2
cat *.log Redirect command output to the input of zip r archive.zip <files> (create)
Bring down a network interface:
Changing directories: another command: unzip t archive.zip (test / list)
List “regular” files with bug in their name: ifconfig eth0 down
cd newdir cat *.log | grep error unzip archive.zip (extract)
ls *bug*
cd .. (parent directory) Define a default gateway for packets to
cd (previous directory) List all “regular” files ending with . and a Job control Printing machines outside the local network:
cd (home directory) single character: route add default gw 192.168.0.1
Show all running processes: Send PostScript or text files to queue:
cd ~bill (home directory of user bill) ls *.?
ps ef lpr Pqueue f1.ps f2.txt (local printer) Delete the default route:
Print the working (current) directory: route del default
pwd
Handling file contents Live hit-parade of processes (press P, M, T: sort List all the print jobs in queue:
Show only the lines in a file containing a given by Processor, Memory or Time usage): lpq Pqueue Test networking with another machine:
Copy a file to another: top ping 207.46.130.108
substring: Cancel a print job number in queue:
cp source_file dest_file grep substring file Send a termination signal to a process: cancel 123 queue Create or remove partitions on the first IDE
Copy files to a directory: kill <pid> (number found in ps output) hard disk:
Case insensitive search:
cp file1 file2 dir Print a PDF file: fdisk /dev/hda1
grep i substring file Have the kernel kill a process: pdf2ps doc.pdf
Copy directories recursively: kill 9 <pid> lpr doc.ps Create (format) an ext3 filesystem:
Showing all the lines but the ones containing a
cp r source_dir dest_dir substring: mkfs.ext3 /dev/hda1
rsync a source_dir/ dest_dir/ Kill all processes (at least all user ones): View a PostScript file:
grep v substring file kill 9 1 Create (format) a FAT32 filesystem:
ps2pdf doc.ps
Create a symbolic link: Search through all the files in a directory: xpdf doc.pdf mkfs.vfat v F 32 /dev/hda2
ln s linked_file link Kill a graphical application:
grep r substring dir xkill (click on the program window to kill) Mount a formatted partition:
Rename a file, link or directory: User management mkdir /mnt/usbdisk (just do it once)
Sort lines in a given file:
mv source_file dest_file sort file File and partition sizes List users logged on the system: mount /dev/uba1 /mnt/usbdisk
who
Remove files or links: Sort lines, only display duplicate ones once: Show the total size on disk of files or Mount a filesystem image (loop device):
rm file1 file2 sort u file (unique) directories (disk usage): Show which user I am logged as: mount o loop initrd.img /mnt/initrd
du sh dir1 dir2 file1 file2 whoami
Remove empty directories: Unmount a filesystem:
rmdir dir Changing file access rights Number of bytes, words and lines in file: Show which groups user belongs to: umount /mnt/usbdisk
Add write permissions to the current user: wc file (word count) groups user
Remove non-empty directories: Check the system kernel version:
rm rf dir chmod u+w file Show the size, total space and free space of the uname a
Tell more information about user:
Add read permissions to users in the file group: current partition: finger user
Listing files chmod g+r file df h .
Switch to user hulk:
List all “regular” files (not starting with .) in Add execute permissions to other users: Display these info for all partitions: su hulk
the current directory: chmod o+x file df h
ls Switch to super user (root):