Académique Documents
Professionnel Documents
Culture Documents
it/commands
Our sponsors | Become sponsor - without any sponsor our work would be impossible, thank you
| System information | Shutdown, Restart and Logout of a system | Files and Directory | File search | Mounting a Filesystem | Disk Space | Users and Groups | Permits on Files | Special Attributes on files | Archives and compressed files | RPM Packages ( Fedora, Red Hat and like) | YUM packages tool (Fedora, RedHat and alike) | DEB packages (Debian, Ubuntu and like) | APT packages tool (Debian, Ubuntu and alike) | View file content | Text Manipulation | Character set and Format file conversion | Filesystem Analysis | Format a Filesystem | Filesystem SWAP | Backup | CDROM | Networking (LAN / WiFi) | Microsoft Windows networks (samba) | IPTABLES (firewall) | Monitoring and debugging | Others useful commands | Pacman packages tool (Arch, Frugalware and alike) |
System information
Command # arch # cal 2007 # cat /proc/cpuinfo # cat /proc/interrupts # cat /proc/meminfo # cat /proc/swaps # cat /proc/version # cat /proc/net/dev # cat /proc/mounts # clock -w # date Description show architecture of machine(1) [man] show the timetable of 2007 [man] show information CPU info [man] show interrupts [man] verify memory use [man] show file(s) swap [man] show version of the kernel [man] show network adpters and statistics [man] show mounted file system(s) [man] save date changes on BIOS [man] show system date [man]
1 of 20
14/11/2011 19:27
# date 041217002007.00 # dmidecode -q # hdparm -i /dev/hda # hdparm -tT /dev/sda # lspci -tv # lsusb -tv # uname -m # uname -r TOP
set date and time MonthDayhoursMinutesYear.Seconds [man] show hardware system components - (SMBIOS / DMI) [man] displays the characteristics of a hard-disk [man] perform test reading on a hard-disk [man] display PCI devices [man] show USB devices [man] show architecture of machine(2) [man] show used kernel version [man]
2 of 20
14/11/2011 19:27
# cp dir/* . # cp -a /tmp/dir1 . # cp -a dir1 dir2 # cp file file1 # iconv -l # iconv -f fromEncoding -t toEncoding inputFile > outputFile # find . -maxdepth 1 -name *.jpg -print -exec convert # ln -s file1 lnk1 # ln file1 lnk1 # ls # ls -F # ls -l # ls -a # ls *[0-9]* # lstree # mkdir dir1 # mkdir dir1 dir2 # mkdir -p /tmp/dir1/dir2 # mv dir1 new_dir # pwd # rm -f file1 # rm -rf dir1 # rm -rf dir1 dir2 # rmdir dir1 # touch -t 0712250000 file1 # tree
copy all files of a directory within the current work directory [man] copy a directory within the current work directory [man] copy a directory [man] outputs the mime type of the file as text [man] lists known encodings [man] converting the coding of characters from one format to another [man] batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick) [man] create a symbolic link to file or directory [man] create a physical link to file or directory [man] view files of directory [man] view files of directory [man] show details of files and directory [man] show hidden files [man] show files and directory containing numbers [man] show files and directories in a tree starting from root(2) [man] create a directory called 'dir1' [man] create two directories simultaneously [man] create a directory tree [man] rename / move a file or directory [man] show the path of work directory [man] delete file called 'file1' [man] remove a directory called 'dir1' and contents recursively [man] remove two directories and their contents recursively [man] delete directory called 'dir1' [man] modify timestamp of a file or directory (YYMMDDhhmm) [man] show files and directories in a tree starting from root(1) [man] Linux Command Line written by LinuxGuide.it (Credits)
TOP
3 of 20
14/11/2011 19:27
File search
Command # find / -name file1 # find / -user user1 # find /home/user1 -name \*.bin # find /usr/bin -type f -atime +100 # find /usr/bin -type f -mtime -10 # find / -name *.rpm -exec chmod 755 '{}' \; # find / -xdev -name \*.rpm Description search file and directory into root filesystem from '/' [man] search files and directories belonging to 'user1' [man] search files with '. bin' extension within directory '/ home/user1' [man] search binary files are not used in the last 100 days [man] search files created or changed within 10 days [man] search files with '.rpm' extension and modify permits [man] search files with '.rpm' extension ignoring removable partitions as cdrom, pen-drive, etc. [man] find files with the '.ps' extension - first run 'updatedb' command [man] show location of a binary file, source or man [man] show full path to a binary / executable [man] Linux Command Line written by LinuxGuide.it (Credits) TOP
Mounting a Filesystem
Command # fuser -km /mnt/hda2 # mount /dev/hda2 /mnt/hda2 # mount /dev/fd0 /mnt/floppy # mount /dev/cdrom /mnt/cdrom # mount /dev/hdc /mnt/cdrecorder # mount /dev/hdb /mnt/cdrecorder # mount -o loop file.iso /mnt/cdrom # mount -t vfat /dev/hda5 /mnt/hda5 # mount /dev/sda1 /mnt/usbdisk Description force umount when the device is busy [man] mount disk called hda2 - verify existence of the directory '/ mnt/hda2' [man] mount a floppy disk [man] mount a cdrom / dvdrom [man] mount a cdrw / dvdrom [man] mount a cdrw / dvdrom [man] mount a file or iso image [man] mount a Windows FAT32 file system [man] mount a usb pen-drive or flash-drive [man]
4 of 20
14/11/2011 19:27
# mount -t smbfs -o username=user,password=pass //WinClient /share /mnt/share # umount /dev/hda2 # umount -n /mnt/hda2
unmount disk called hda2 - exit from mount point '/ mnt/hda2' first [man] run umount without writing the file /etc/mtab useful when the file is read-only or the hard disk is full [man]
Disk Space
Command # df -h # dpkg-query -W -f='${InstalledSize;10}t${Package}n' | sort -k1,1n # du -sh dir1 # du -sk * | sort -rn # ls -lSr |more Description show list of partitions mounted [man] show the used space by installed deb packages, sorting by size (debian, ubuntu and alike) [man] estimate space used by directory 'dir1' [man] show size of the files and directories sorted by size [man] show size of the files and directories ordered by size [man]
# rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort show the used space by rpm packages installed -k1,1n sorted by size (fedora, redhat and alike) [man] Linux Command Line written by LinuxGuide.it (Credits) TOP
5 of 20
14/11/2011 19:27
# passwd user1 # pwck # useradd -c "User Linux" -g admin -d /home/user1 -s /bin/bash user1 # useradd user1 # userdel -r user1
change a user password (only by root) [man] check correct syntax and file format of '/etc/passwd' and users existence [man] create a new user "user1" belongs "admin" group [man] create a new user [man] delete a user ( '-r' eliminates home directory) [man]
# usermod -c "User FTP" -g system -d /ftp/user1 change user attributes as description, group and -s /bin/nologin user1 other [man] Linux Command Line written by LinuxGuide.it (Credits) TOP
Permits on Files
Command # chgrp group1 file1 # chmod ugo+rwx directory1 # chmod go-rwx directory1 # chmod u+s /bin/file1 # chmod u-s /bin/file1 # chmod g+s /home/public # chmod g-s /home/public # chmod o+t /home/public # chmod o-t /home/public # chown user1 file1 # chown -R user1 directory1 # chown user1:group1 file1 # find / -perm -u+s # ls -lh # ls /tmp | pr -T5 -W$COLUMNS TOP Description change group of files [man] set permissions reading (r), write (w) and (x) access to users owner (u) group (g) and others (o) [man] remove permits reading (r), write (w) and (x) access to users group (g) and others (or [man] set SUID bit on a binary file - the user that running that file gets same privileges as owner [man] disable SUID bit on a binary file [man] set SGID bit on a directory - similar to SUID but for directory [man] disable SGID bit on a directory [man] set STIKY bit on a directory - allows files deletion only to legitimate owners [man] disable STIKY bit on a directory [man] change owner of a file [man] change user owner of a directory and all the files and directories contained inside [man] change user and group ownership of a file [man] view all files on the system with SUID configured [man] show permits on files [man] divide terminal into 5 columns [man]
6 of 20
14/11/2011 19:27
7 of 20
14/11/2011 19:27
# tar -xvf archive.tar -C /tmp # tar -cvfj archive.tar.bz2 dir1 # tar -xvfj archive.tar.bz2 # tar -cvfz archive.tar.gz dir1 # tar -xvfz archive.tar.gz # unrar x file1.rar # unzip file1.zip # zip file1.zip file1 # zip -r file1.zip file1 file2 dir1
extract a tarball into / tmp [man] create a tarball compressed into bzip2 [man] decompress a compressed tar archive in bzip2 [man] create a tarball compressed into gzip [man] decompress a compressed tar archive in gzip [man] decompress rar archive [man] decompress a zip archive [man] create an archive compressed in zip [man] compress in zip several files and directories simultaneously [man]
8 of 20
14/11/2011 19:27
# rpm -q [package] --scripts # rpm -q [package] --changelog # rpm -qf /etc/httpd/conf/httpd.conf # rpm -qp [package.rpm] -l # rpm --import /media/cdrom/RPM-GPG-KEY # rpm --checksig [package.rpm] # rpm -qa gpg-pubkey # rpm -V [package] # rpm -Va # rpm -Vp [package.rpm] # rpm -ivh /usr/src/redhat/RPMS/`arch` /[package.rpm] # rpm2cpio [package.rpm] | cpio --extract --make-directories *bin* # rpmbuild --rebuild [package.src.rpm] TOP
show scripts started during installation / removal [man] show history of revisions of a rpm package [man] verify which rpm package belongs to a given file [man] show list of files provided by a rpm package not yet installed [man] import public-key digital signature [man] verify the integrity of a rpm package [man] verify integrity of all rpm packages installed [man] check file size, permissions, type, owner, group, MD5 checksum and last modification [man] check all rpm packages installed on the system - use with caution [man] verify a rpm package not yet installed [man] install a package built from a rpm source [man] extract executable file from a rpm package [man] build a rpm package from a rpm source [man]
# yum -y update # yum update [package] # yum remove [package] # yum list # yum search [package] # yum clean [package] # yum clean headers
9 of 20
14/11/2011 19:27
remove from the cache packages and headers files [man] Linux Command Line written by LinuxGuide.it (Credits)
TOP
10 of 20
14/11/2011 19:27
Text Manipulation
Command # cat example.txt | awk 'NR%2==1' # echo a b c | awk '{print $1}' # echo a b c | awk '{print $1,$3}' # cat -n file1 # comm -1 file1 file2 Description remove all even lines from example.txt [man] view the first column of a line [man] view the first and third column of a line [man] number row of a file [man] compare contents of two files by deleting only unique lines from 'file1' [man]
11 of 20
14/11/2011 19:27
# comm -2 file1 file2 # comm -3 file1 file2 # diff file1 file2 # grep Aug /var/log/messages # grep ^Aug /var/log/messages # grep [0-9] /var/log/messages # grep Aug -R /var/log/* # paste file1 file2 # paste -d '+' file1 file2 # sdiff file1 file2 # sed 's/string1/string2/g' example.txt # sed '/^$/d' example.txt # sed '/ *#/d; /^$/d' example.txt # sed -e '1d' exampe.txt # sed -n '/string1/p' # sed -e 's/ *$//' example.txt # sed -e 's/string1//g' example.txt # sed -n '1,5p' example.txt # sed -n '5p;5q' example.txt # sed -e 's/00*/0/g' example.txt # sort file1 file2 # sort file1 file2 | uniq # sort file1 file2 | uniq -u # sort file1 file2 | uniq -d # echo 'word' | tr '[:lower:]' '[:upper:]'
compare contents of two files by deleting only unique lines from 'file2' [man] compare contents of two files by deleting only the lines that appear on both files [man] find differences between two files [man] look up words "Aug" on file '/var/log/messages' [man] look up words that begin with "Aug" on file '/var/log /messages' [man] select from file '/var/log/messages' all lines that contain numbers [man] search string "Aug" at directory '/var/log' and below [man] merging contents of two files for columns [man] merging contents of two files for columns with '+' delimiter on the center [man] find differences between two files and merge interactively alike "diff" [man] replace "string1" with "string2" in example.txt [man] remove all blank lines from example.txt [man] remove comments and blank lines from example.txt [man] eliminates the first line from file example.txt [man] view only lines that contain the word "string1" [man] remove empty characters at the end of each row [man] remove only the word "string1" from text and leave intact all [man] print from 1th to 5th row of example.txt [man] print row number 5 of example.txt [man] replace more zeros with a single zero [man] sort contents of two files [man] sort contents of two files omitting lines repeated [man] sort contents of two files by viewing only unique line [man] sort contents of two files by viewing only duplicate line [man] convert from lower case in upper case [man]
12 of 20
14/11/2011 19:27
Filesystem Analysis
Command # badblocks -v /dev/hda1 # dosfsck /dev/hda1 # e2fsck /dev/hda1 # e2fsck -j /dev/hda1 # fsck /dev/hda1 # fsck.ext2 /dev/hda1 # fsck.ext3 /dev/hda1 # fsck.vfat /dev/hda1 # fsck.msdos /dev/hda1 Description check bad blocks on disk hda1 [man] repair / check integrity of dos filesystems on disk hda1 [man] repair / check integrity of ext2 filesystem on disk hda1 [man] repair / check integrity of ext3 filesystem on disk hda1 [man] repair / check integrity of linux filesystem on disk hda1 [man] repair / check integrity of ext2 filesystem on disk hda1 [man] repair / check integrity of ext3 filesystem on disk hda1 [man] repair / check integrity of fat filesystem on disk hda1 [man] repair / check integrity of dos filesystem on disk hda1 [man]
13 of 20
14/11/2011 19:27
Format a Filesystem
Command # fdformat -n /dev/fd0 # mke2fs /dev/hda1 # mke2fs -j /dev/hda1 # mkfs /dev/hda1 # mkfs -t vfat 32 -F /dev/hda1 # mkswap /dev/hda3 TOP Description format a floppy disk [man] create a filesystem type linux ext2 on hda1 partition [man] create a filesystem type linux ext3 (journal) on hda1 partition [man] create a filesystem type linux on hda1 partition [man] create a FAT32 filesystem [man] create a swap filesystem [man] Linux Command Line written by LinuxGuide.it (Credits)
Filesystem SWAP
Command # mkswap /dev/hda3 # swapon /dev/hda3 # swapon /dev/hda2 /dev/hdb3 TOP Description create a swap filesystem [man] activating a new swap partition [man] activate two swap partitions [man]
Backup
Command # find /var/log -name '*.log' | tar cv --filesfrom=- | bzip2 > log.tar.bz2 # find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents # dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' # dd if=/dev/sda of=/tmp/file1 # dd if=/dev/hda of=/dev/fd0 bs=512 count=1 Description find all files with '.log' extention and make an bzip archive [man] find and copy all files with '.txt' extention from a directory to another [man] make a backup of a local hard disk on remote host via ssh [man] backup content of the harddrive to a file [man] make a copy of MBR (Master Boot Record) to floppy [man]
14 of 20
14/11/2011 19:27
# dd if=/dev/fd0 of=/dev/hda bs=512 count=1 # dump -0aj -f /tmp/home0.bak /home # dump -1aj -f /tmp/home0.bak /home # restore -if /tmp/home0.bak # rsync -rogpav --delete /home /tmp # rsync -rogpav -e ssh --delete /home ip_address:/tmp
restore MBR from backup copy saved to floppy [man] make a full backup of directory '/home' [man] make a incremental backup of directory '/home' [man] restoring a backup interactively [man] synchronization between directories [man] rsync via SSH tunnel [man]
# rsync -az -e ssh --delete ip_addr:/home/public synchronize a local directory with a remote /home/local directory via ssh and compression [man] # rsync -az -e ssh --delete /home/local ip_addr:/home/public # tar -Puf backup.tar /home/user # ( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' # ( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' # tar cf - . | (cd /tmp/backup ; tar xf - ) synchronize a remote directory with a local directory via ssh and compression [man] make a incremental backup of directory '/home/user' [man] copy content of a directory on remote directory via ssh [man] copy a local directory on remote directory via ssh [man] local copy preserving permits and links from a directory to another [man]
CDROM
Command # cd-paranoia -B # cd-paranoia -# cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force # cdrecord -v dev=/dev/cdrom cd.iso Description rip audio tracks from a CD to wav files [man] rip first three audio tracks from a CD to wav files [man] clean a rewritable cdrom [man] burn an ISO image [man]
# gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom burn a compressed ISO image [man] # cdrecord --scanbus # dd if=/dev/hdc | md5sum # mkisofs /dev/cdrom > cd.iso # mkisofs /dev/cdrom | gzip > cd_iso.gz scan bus to identify the channel scsi [man] perform an md5sum on a device, like a CD [man] create an iso image of cdrom on disk [man] create a compressed iso image of cdrom on disk [man]
15 of 20
14/11/2011 19:27
16 of 20
14/11/2011 19:27
show all HTTP traffic [man] lookup on Whois database [man] Linux Command Line written by LinuxGuide.it (Credits)
netbios name resolution [man] netbios name resolution [man] show remote shares of a windows host [man] like wget can download files from a host windows via smb [man]
IPTABLES (firewall)
Command # iptables -t filter -L # iptables -t nat -L # iptables -t filter -F # iptables -t nat -F # iptables -t filter -X Description show all chains of filtering table [man] show all chains of nat table [man] clear all rules from filtering table [man] clear all rules from table nat [man] delete any chains created by user [man]
# iptables -t filter -A INPUT -p tcp --dport telnet allow telnet connections to input [man] -j ACCEPT # iptables -t filter -A OUTPUT -p tcp --dport http -j DROP # iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT block HTTP connections to output [man] allow POP3 connections to forward chain [man]
# iptables -t filter -A INPUT -j LOG --log-prefix Logging on input chain [man] # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp --dport 22 -j DNAT --to-destination 10.0.0.2:22 configure a PAT (Port Address Traslation) on eth0 masking outbound packets [man] redirect packets addressed to a host to another host [man]
17 of 20
14/11/2011 19:27
18 of 20
14/11/2011 19:27
command [man] # chsh # chsh --list-shells # gpg -c file1 # gpg file1.gpg # ldd /usr/bin/ssh # man ping change shell command [man] nice command to know if you have to remote into another box [man] encrypt a file with GNU Privacy Guard [man] decrypt a file with GNU Privacy Guard [man] show shared libraries required by ssh program [man] display the on-line manual pages for example on ping command - use '-k' option to find any related commands [man] create a boot floppy [man] download an entire web site [man] download a file with the ability to stop the download and resume later [man]
# echo 'wget -c www.example.com/files.iso' | at start a download at any given time [man] 09:00 # whatis ...keyword # who -a displays description of what a program does [man] show who is logged on, and print: time of last system boot, dead processes, system login processes, active processes spawned by init, current runlevel, last system clock change [man] Linux Command Line written by LinuxGuide.it (Credits) TOP
19 of 20
14/11/2011 19:27
No Derivative Works You may not alter, transform, or build upon this work. For any reuse or distribution, you must make clear to others the licence terms of this work. Any of the above conditions can be waived if you get permission from the copyright holder. The author's moral rights are retained in this licence. Conditions for use Linux Command Line's commands: USE AT YOUR OWN RISK . YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR LOSS OF DATA THAT RESULTS FROM THE USE OF ANY SUCH MATERIAL.
TOP
20 of 20
14/11/2011 19:27