[go: up one dir, main page]

0% found this document useful (0 votes)
156 views1 page

Command Memento

Grep --help Access the full manual page of a command: man grep Displaying file contents Concatenate and display file contents: cat file1 file2 display the contents of several files (stopping at each page)

Uploaded by

famoza81
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views1 page

Command Memento

Grep --help Access the full manual page of a command: man grep Displaying file contents Concatenate and display file contents: cat file1 file2 display the contents of several files (stopping at each page)

Uploaded by

famoza81
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

GNU/Linux most wanted ls -ltr diff file1 file2 gunzip file.

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

You might also like