linux basic instruction record

The system displays information arch architecture of machine (1) uname -m show architecture of machine (2) uname -r dmidecode -q kernel version is being displayed using the display hardware system components - (SMBIOS / DMI) hdparm -i / dev / hda listed architecture features a disk hdparm -tT / dev / sda test is performed on a magnetic disk of a read operation system information
arch show architecture of machine (. 1)
the uname -m show architecture of machine (2)
the uname -r kernel version is displayed using
dmidecode -q display hardware system components - (the SMBIOS / the DMI)
hdparm -i / dev / HDA listed architecture features a disk
hdparm -tT / dev / sda perform a test of a read operation on the disk
cat / proc / cpuinfo show information CPU info
cat / proc / interrupts show interrupts
cat / proc / meminfo verify memory use
cat / proc / swaps show which swap used
cat / proc / version show version of the kernel
cat / proc / net / dev network adapters and display statistics
cat / proc / mounts show mounted file system
lspci -tv listed PCI devices
lsusb -tv show USB device
date display system date
cal 2007 show the 2007 calendar
date 041217002007.00 set date and time - in seconds, month, day, hour
clock -w will save time to modify the BIOS

Shutdown (system shutdown, restart and logout)
the shutdown -H now closed system (. 1)
the init 0 Close system (2)
the telinit 0 Close System (. 3)
the shutdown -H hours: minutes & shutdown of the system time
shutdown -c cancel shutdown of the system time
shutdown -r now restart (. 1)
reboot restart (2)
Zimbabwe Logout logout

Files and directories
cd / home enter '/ home' directory '
cd .. go back one level
cd ../ .. Return two directory
cd go to home directory
cd ~ user1 go to home directory
cd - Return times in the same directory
pwd display the path to the working
file ls to view directories
ls -F view files in a directory
ls -l show details of files and directories
ls -a show hidden files
ls [0-9] displays the file name containing numbers and directory name
tree displays a tree structure of files and directories starting from the root directory (1)
lstree displays a tree structure of files and directories starting from the root (2)
mkdir dir1 create one called 'dir1' directory '
mkdir dir1 dir2 while creating two directories
mkdir -p / tmp / dir1 / dir2 create a directory tree
rm -f file1 delete called 'file1' file '
rmdir dir1 delete called' dir1 'directory'
RM -rf dir1 delete called 'dir1' directory and delete its contents
rm -rf dir1 dir2 remove two directories at the same time and their contents
mv dir1 new_dir rename / move a directory
cp file1 file2 copying a file
cp dir / . Copy all files in a directory to the current working directory
cp -a / tmp / dir1. copy a directory within the current work directory
cp -a dir1 dir2 copy a directory
ln -s file1 lnk1 create pointing to a file or directory soft link
ln file1 lnk1 create a link to the file or directory link physical
touch -t 0712250000 file1 modify a file or directory timestamp - (YYMMDDhhmm)
file file1 the Outputs at the MIME of the type of text at the file AS
iconv - l List known encoding
iconv -f -t toEncoding fromEncoding inputFile> from the outputFile Creates new new a GIVEN INPUT the File encoded by Assuming IT iS IT in fromEncoding and Converting to toEncoding.
Find. 1 -maxdepth -name.
.jpg -print - exec convert "{}" -resize 80x60 "thumbs / {}" \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)

File search
find / -name file1 from '/' began to enter the root file system search for files and directories
find / -user user1 search belongs to the user 'user1' files and directories
find / home / user1 -name * .bin in the directory '/ home file / user1 'searches with' ending .bin 'the
find / usr / bin -type f -atime +100 searched in the past 100 days has not been used to perform a file
find / usr / bin -type f -mtime -10 Search created or modified file within 10 days
find / -name * .rpm -exec chmod 755 '{}' \; search files ending in '.rpm' and define permissions
find / -xdev -name * .rpm Search to the end of the file '.rpm', ignoring the CDROM, pen-drive and other removable devices
locate * .ps looking to '.ps' end of the document - first run 'updatedb' command
whereis halt show a binary file, source or man of position
which halt show full path to a binary file or executable file

Mount a file system
mount / dev / hda2 / mnt / hda2 mount a disk called hda2 - determine the directory '/ mnt / hda2' already exists
umount / dev / hda2 unloading a disk called hda2 - start with the mount point ' / mnt / hda2 'exit
fuser -km / mnt / hda2 forced to unload when the device is busy
umount -n / mnt / hda2 run umount without writing / etc / mtab file - when the file is read or when the disk is full very useful
mount / dev / fd0 / mnt / floppy mount a floppy disk
mount / dev / cdrom / mnt / cdrom to mount a cdrom or dvdrom
Mount / dev / HDC / mnt / cdrecorder mount a cdrw or dvdrom
Mount / dev / hdb / mnt / cdrecorder or mount a cdrw dvdrom
Mount -o Loop file.iso / mnt / CDROM mount an ISO image file or
mount -t vfat / dev / hda5 / mnt / hda5 mount a Windows FAT32 file system
mount / dev / sda1 / mnt / usbdisk mount a disk or flash usb pen
mount -t smbfs -o username = user, password = pass // WinClient / share / mnt / share mount a windows network share

Disk Space
df -h display has been mounted partition list
ls -lSr | more aligned to the size of the files and directories
du -sh dir1 estimate disk space directory 'dir1' already used '
du -sk * | -rn with a capacity size of the Sort sequentially displayed based on the size of files and directories
rpm -q -a --qf '% 10 { sIZE} t% {NAME} n' | sort -k1,1n sequentially displayed by size installed rpm packages used space (fedora, redhat based system)
dpkg-Query -W -f = '$ {the installed-size; the package {10} $} n-T' | -k1,1n Sort by size display deb packages installed used space (ubuntu, debian based systems)

Index ^ back to top

Users and Groups
groupadd group_name create a new user group
groupdel group_name delete a user group
groupmod -n new_group_name old_group_name rename a user group
useradd -c "Name Surname" -g admin -d / home / user1 -s / bin / bash user1 Creating a user belongs "admin" user group
useradd user1 create a new user
userdel -r user1 delete a user ( '-r' eliminates home directory)
the usermod -c "the user the FTP" -g System -d / the FTP / user1 -s / bin / nologin user1 modify user attributes
passwd Change password
passwd user1 change a user password (only perform root)
the chage -E 2005-12-31 user1 set password expiration period
pwck check '/ etc / passwd' file format and grammatical corrections and user presence
grpck check '/ etc / passwd' file format and syntax correction as well as the presence of a group of
newgrp group_name log into a new group to change default group of newly created files

Index ^ back to top

File permissions - using the "+" to set permissions, use the "-" is used to cancel
ls -lh permission to display the
ls / tmp | pr -T5 -W $ COLUMNS divide terminal into 5 columns will show
chmod ugo + rwx directory1 set all directory people (u), group (g) and others (o) to read (r), write (w) and execute permissions (x),
chmod go-rwx directory1 delete a group (g) and others (o) perform read and write access to a directory
chown user1 file1 change owner of a file's properties
chown -R user1 directory1 change all of the properties of a directory and also change the attributes of all files in the directory to change
the group chgrp group1 file1 change file
chown user1: group1 file1 change a file and group ownership of the
find / -perm -u + s list of all uses a file system control SUID
chmod u + s / bin / file1 set SUID bit on a binary file - run the file the user is also given the same permissions and owner
chmod us / bin / file1 disable SUID bit on a binary file
chmod g + s / home / public set SGID bit on a directory - similar to SUID, but this is for directory
chmod gs / home / public disable SGID bit on a directory
chmod o + t / home / public set a STIKY bit files - delete files allow only legitimate owners
chmod ot / home / public disable a catalog of STIKY bit

Index ^ back to top

Special attributes files - using the "+" to set permissions, "-" is used to cancel
chattr + a file1 append mode allows only read or write files
chattr + c file1 allows that a file is automatically compressed kernel / decompression
chattr + d file1 in when a file system backup, the dump program ignores file
chattr + i file1 an immutable file can not be deleted, modify, rename, or linked
chattr + s file1 allows a file to be safely deleted
chattr + S file1 upon application programs have been written on this file, the system immediately modify the results written to disk
chattr + u file1 If the file is deleted, the system will allow you to recover the contents of a file is deleted
lsattr show special properties

Index ^ back to top

Packaged and compressed files
file1.bz2 decompression called bunzip2 'file1.bz2' file
compression called bzip2 file1 'file1' files
gunzip file1.gz decompression called 'file1.gz' file
gzip file1 compress called 'file1' file
gzip -9 file1 maximize compression
rar a file1.rar test_file created called 'file1.rar' package
rar a file1.rar file1 file2 dir1 while compressing 'file1', 'file2' and the directory 'dir1'
RAR the X-file1 packet decompression .rar rar
unrar x file1.rar packet extracting rar
tar -cvf archive.tar file1 create a non-compressed the tarball
tar -cvf archive.tar file1 file2 dir1 created containing a 'file1', 'file2' and 'dir1' archive
tar -tf archive.tar display the contents of a package
tar -xvf archive.tar release a package
tar -xvf archive.tar -C / tmp to release the compressed packet / tmp catalog
tar -cvfj archive.tar.bz2 dir1 create a bzip2 compressed format
tar -xvfj archive.tar.bz2 extracting archive a bzip2 format of
tar -cvfz archive.tar.gz dir1 create a compressed gzip format of
tar -xvfz archive.tar.gz decompress a gzip format compressed
zip file1.zip file1 create a zip format compressed
zip -r file1.zip file1 file2 dir1 several files and directories simultaneously compressed into a zip archive format
unzip file1.zip extracting a zip format archive

Index ^ back to top

RPM Package - (Fedora, Redhat and similar systems)
rpm -ivh package.rpm install a rpm package
rpm -ivh --nodeeps package.rpm install a rpm package while ignoring dependencies
rpm -U package.rpm upgrade a rpm package but does not change its configuration file
rpm -F package.rpm update a determined already installed rpm package
rpm -e delete package_name.rpm a rpm package
rpm -qa show all rpm packages installed
rpm -qa | grep httpd show all names contains the word "httpd" rpm package
rpm -qi package_name obtain a special information package installed
rpm -qg "System Environment / Daemons" show a package assembly rpm
rpm -ql package_name display a file installed rpm package provided list
rpm -qc package_name a display installed rpm package list of profiles
rpm -q package_name --whatrequires rpm package displays a list of dependencies
rpm -q package_name --whatprovides rpm package displays a volume occupied
rpm -q package_name --scripts displayed in the script l / deleted during the installation performed
rpm -q package_name --changelog show a modification history rpm package
rpm -qf /etc/httpd/conf/httpd.conf to confirm the documents which rpm package from the
rpm -qp package.rpm -l displayed by an as yet list of files installed rpm package provided
rpm --import / media / cdrom / RPM -GPG-KEY digital certificate of a public key
rpm --checksig package.rpm confirm the integrity of a rpm package
rpm -qa gpg-pubkey confirm installed the integrity of all rpm package
rpm -V package_name check file size, permissions, type, owner, group, MD5 checksum and last modification time
rpm -Va inspection systems all installed rpm package - used with care
rpm -Vp package .rpm confirm a rpm package not yet installed
rpm2cpio package.rpm | cpio Directories --extract --make- bin executable file from a rpm package run
rpm -ivh / usr / src / RedHat / RPMS / arch/package.rpm from a rpm source mounting a package built
rpmbuild --rebuild package_name.src.rpm a construct from a source rpm package rpm

Index ^ back to top

YUM packages updater - (Fedora, RedHat and similar systems)
yum install package_name download and install a rpm package
yum localinstall package_name.rpm will install a rpm package, use your own software repository for you to solve all dependencies
yum update package_name. rpm update the current system for all installed rpm package
yum update package_name upgrade a rpm package
yum remove package_name remove a rpm package
yum list list all packages that are currently installed on the system
yum search package_name search for packages in the warehouse rpm
yum clean packages cleanup rpm cache delete the downloaded package
yum clean headers remove all header files
yum clean all remove all cached packages and header files

Index ^ back to top

DEB packages (Debian, Ubuntu and similar systems)
dpkg -i package.deb install / upgrade a deb package
dpkg -r package_name remove a deb package from the system
dpkg -l show all deb packages installed
dpkg -l | grep httpd show all whose names contain the word "httpd" deb package
dpkg -s package_name obtain information system has been installed in a special package of
documents a deb package dpkg -L package_name display system has been installed in the list provided
dpkg --contents package display a list of files .deb package not yet installed the provided
dpkg -S / bin / ping to confirm which documents provided by the deb package

Index ^ back to top

APT software tool (Debian, Ubuntu and similar systems)
APT-GET install package_name install / upgrade a deb package
apt-cdrom install package_name install from a CD / upgrade a deb package
package apt-get update update the list of
apt-get upgrade upgrade All installed software
apt-get remove package_name removed from the system a deb package
apt-get check confirmation of dependencies correctly
apt-get clean clean up cache from packages downloaded
apt-cache search searched-package returns list of search characters string package name

Index ^ back to top

Look at the file
cat file1 view the contents of the file forward from the first byte
tac file1 in reverse, starting from the last row view the contents of a file of
more file1 view the contents of a long file of
less file1 similar to 'more' command, but it file and allow the same operation as the forward reverse operation of
the first two rows of the head to view a file file1 -2
tail -2 file1 view last two lines of a file
tail -f / var / log / messages in real time a file is added to the view contents

Index ^ back to top

Text Processing
CAT file1 file2 ... | the Command <> file1_in.txt_or_file1_out.txt General Manipulation text syntax for a using PIPE, STDIN and STDOUT
CAT file1 | the Command (sed, grep, awk, grep, etc ...)> result.txt a detailed description of the combined text file and write a new introduction file
cat file1 | command (sed, grep , awk, grep, etc ...) >> result.txt merger described in detail a text file, and About write an existing file
grep Aug / var / log / messages in the file '/ var / log / messages' in the keyword to find "Aug"
grep ^ Aug / var / log / messages in the file' / var / log / messages' to find "Aug" words beginning
grep [0-9] / var / log / messages select '/ var / log / messages' file numbers of all lines contained
grep Aug -R / var / log / in directory '/ var / log' and subsequent directory search string "-Aug"
Sed 'S / stringa1 / stringa2 / G' example.txt in example.txt the "string1" replace "string2"
sed '/ ^ $ / d' example.txt example.txt remove all blank lines from a file
sed '/
# / d; / ^ $ / d 'example.txt example.txt deleted from the document, all comments and blank lines
echo' esempio '| tr' [ : lower:] '' [: upper:] ' merge cell contents up and down
sed -e '1d' result.txt example.txt excluded from the first line in the file
sed -n '/ stringa1 / p' contains only See Glossary "string1" row
Sed -e 'S / $ //' example.txt delete each line of the last blank character
sed -e 's / stringa1 // g ' example.txt only delete words "string1" from the document and retain all remaining
sed -n '1,5p; 5q' example.txt View from 5, line to line content
sed -n '5p; 5q' example.txt view line 5
Sed -e 'S / 00
/0 / G' example.txt replaced with a plurality of single zero zero
cat -n file1 file designated the number of rows
cat example.txt | all even rows awk 'NR% 2 == 1' delete example.txt file
echo abc | awk '{print $ 1}' view the first column of a line
echo abc | awk '{print $ 1 , 3} $ 'The first and third bar to view a line
paste file1 file2 merging contents of two files or two columns
paste -d '+' file1 file2 merging contents of two files or two columns, with the intermediate "+" to distinguish
two files sort file1 file2 sort
sort file1 file2 | uniq union of two files (lines repeated Keep a)
the Sort file1 file2 | uniq -u files by viewing only unique line
sort file1 file2 | uniq -d sort contents of two files (leaving only exist in both files in the file)
COMM -1 file1 SUMMARY file2 compare two files by deleting only the content 'file1' contained
comm content file1 file2 compare two files -2 only delete the contents 'file2' contained
comm content file1 file2 compare two files -3 deleting only two There are parts of files

Index ^ back to top

Character Set and file format conversion
dos2unix filedos.txt fileunix.txt to convert a text file format from MSDOS to UNIX
of unix2dos stood in fileunix.txt filedos.txt to convert a text file format from UNIX to MSDOS
Recode ..HTML <page.txt > page.html convert a text file into HTML
Recode the -l | More display format allows the conversion of all

Index ^ back to top

File System Analysis
badblocks -v / dev / hda1 bad blocks on the magnetic disk check hda1
fsck / dev / hda1 repair / check on disk hda1 linux file system integrity
fsck.ext2 / dev / hda1 ext2 file on repair / inspection disk hda1 integrity of the system
e2fsck / dev / hda1 repair / check on disk hda1 ext2 file system integrity
e2fsck -j / dev / hda1 repair / check ext3 filesystem on disk hda1 integrity
fsck.ext3 / dev / hda1 repair / check integrity of ext3 filesystem on disk hda1
the fsck.vfat / dev / hda1 repair / check integrity of fat filesystem on disk hda1 of
fsck.msdos / dev / hda1 repair / check on disk hda1 dos file system integrity
dosfsck / dev integrity / hda1 repair / check dos filesystem on disk hda1

Index ^ back to top

Initialize a file system
mkfs / dev / hda1 create a filesystem on hda1 partition
mke2fs / dev / hda1 create a filesystem type linux ext2 on hda1 partition
mke2fs -j / dev / hda1 create a linux ext3 (journaled) on hda1 partition file system
mkfs -t vfat 32 -F / dev / hda1 create a FAT32 file system
fdformat -n / dev / fd0 a formatted floppy
mkswap / dev / hda3 create a swap file system

Index ^ back to top

SWAP file system
mkswap / dev / hda3 create a swap filesystem
swapon / dev / hda3 enable a new swap file system
swapon / dev / hda2 / dev / hdb3 enable the two swap partitions

Index ^ back to top

Backup
dump -0aj -f /tmp/home0.bak / home making a full backup '/ home' directory
dump -1aj -f /tmp/home0.bak / home make an interactive backup '/ home' directory
restore - if /tmp/home0.bak interactive restore a backup
rsync -rogpav --delete / home / tmp directory synchronization sides
rsync -rogpav -e ssh --delete / home ip_address : / tmp SSH channel through the rsync
the rsync -e -AZ ssh --delete ip_addr: / home / public / home / local ssh and compressed by a remote directory synchronized to the local directory
rsync -az -e ssh --delete / home / local ip_addr: / home / public ssh and compression by the local directory synchronization to a remote directory
dd bs = 1M if = / dev / hda | gzip | ssh user @ ip_addr 'dd of = hda.gz' on the remote host via ssh perform a backup operation of a local disk
dd if = / dev / sda of = / tmp / file1 file backup disk contents to a
tar -Puf backup.tar / home / user to perform a '/ home / user' backup of directory
(Cd / tmp / local / && tar c.) | Ssh -C user @ ip_addr 'cd / home / share / && tar x -p' copy the contents of a directory on remote directory via SSH
(the tar C / Home) | SSH -C user @ ip_addr 'cd / home / backup-home && tar x -p' copy a remote directory in the local directory via SSH
the tar CF2 - |. (CD / tmp / Backup; the tar XF -) local copy a directory to another place, preserving permits and links to
the Find / Home / user1 -name ' .txt' | xargs cp -av --target-directory = / Home / Backup / --parents from one directory to locate and copy all ' .txt 'file to another directory at the end of
the Find / var / log -name'
.log '| tar CV --files-from = - | bzip2> log.tar.bz2 finds all' .log 'end of the file and a package made bzip
dd if = / dev / hda of = / dev / bs = 512 count = 1 to make a copy fd0 MBR (Master Boot Record) to the contents of the diskette operation
dd if = / dev / fd0 of = / dev / hda bs = 512 count = 1 to recover the MBR from backup copy saved to floppy disk contents

Index ^ back to top

Disc
cdrecord -v gracetime = 2 dev = / dev / cdrom -eject blank = fast -force emptying the contents of a rewritable optical disk
mkisofs / dev / cdrom> cd.iso create a disc image file on the disk iso
mkisofs / dev / cdrom | gzip> cd_iso.gz create a compressed disk in the CD iso image file
mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd create iso image files in a directory of
cdrecord -v dev = / dev / cdrom cd.iso burn an ISO image file
gzip -dc cd_iso.gz | cdrecord dev = / dev / cdrom - burn a compressed ISO image
mount -o loop cd.iso / mnt / iso mount an ISO image
cd-paranoia -B transcription from a CD-ROM tracks to wav file
cd-paranoia - "-3" transcribed from a CD-ROM tracks to wav file ( parameter -3)
cdrecord --scanbus scan bus to identify the channel scsi
dd if = / dev / hdc | md5sum md5sum checking a coding device, for example a CD

Index ^ back to top

Network - (Ethernet and wireless WIFI)
the ifconfig eth0 show configuration of an Ethernet card
ifup eth0 enable an interface 'eth0' device
ifdown eth0 a disable interface 'eth0' device
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 IP address control
ifconfig eth0 promisc set 'eth0' promiscuous mode packet sniffing (sniffing)
dhclient eth0 enabled 'eth0' mode to dhcp
route routing Table -n Show
route the Add 0/0 -net IP_GATEWAY configura default GW Gateway
route the Add -net 192.168.0.0 Netmask the configure static route 192.168.1.1 gw 255.255.0.0 to the REACH Network '192.168.0.0/16'
route del 0/0 gw IP_GATEWAY the Remove static route
echo "1"> / proc / SYS / NET / ipv4 / ip_forward of an activate ip routing
hostname Show System of hostname
Host www.example.com lookup hostname to resolve name to ip address and viceversa(1)
nslookup www.example.com lookup hostname to resolve name to ip address and viceversa(2)
ip link show show link status of all interfaces
mii-tool eth0 show link status of 'eth0'
ethtool eth0 show statistics of network card 'eth0'
netstat -tup show all active network connections and their PID
netstat -tupl show all network services listening on the system and their PID
tcpdump tcp port 80 show all HTTP traffic
iwlist scan show wireless networks
iwconfig eth1 show configuration of a wireless network card
hostname show hostname
host www.example.com lookup hostname to resolve name to ip address and viceversa
nslookup www.example.com lookup hostname to resolve name to ip address and viceversa
whois www.example.com lookup on Whois database

GO TOP INDEX ^
Microsoft Windows networks (SAMBA)
nbtscan ip_addr netbios name resolution
nmblookup -A ip_addr netbios name resolution
smbclient -L ip_addr/hostname show remote shares of a windows host
smbget -Rr smb://ip_addr/share like wget can download files from a host windows via smb
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share mount a windows network share

Guess you like

Origin blog.51cto.com/14061503/2430249