Recent major learning Python, so use more Linux systems, except for the LInux system different from the system more commonly used in windows that are mainly used to control command,
So now recording some commonly used commands for easy viewing later use
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 show the path of work
ls view files in a directory
ls -F view files in a directory
ls -l show details of files and directories
ls -a show hidden files
ls * [0-9] * show that contain numbers file and directory names
tree displays a tree structure of files and directories starting from the root directory
lstree display files and directories starting from the root of the tree
mkdir dir1 create a 'dir1' directory is called '
mkdir dir1 dir2 create two directories simultaneously
mkdir -p / tmp / dir1 / dir2 create a directory tree
rm -f file1 delete called 'file1' file '
dir1' directory 'rmdir dir1 delete called'
RM -rf dir1 delete a 'dir1' directory is called and at the same time 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
cp -r dir1 dir2 copy a directory and subdirectories
ln -s file1 lnk1 create a link to the file or directory soft link
ln lnk1 create a link to the file or directory physical link file1
Touch -t 0.71225 billion file1 modify timestamp of a file or directory - (YYMMDDhhmm)
File file1 Outputs the File the MIME type of text AS
iconv -l lists known encoding
iconv -f fromEncoding -t toEncoding inputFile> outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and . Converting to toEncoding IT
. Find. 1 -maxdepth -name * .jpg -print -exec Convert "{}" -resize 80x60 "thumbs / {}" \; BATCH a resize Files in Current Directory The Them to Send and Thumbnails A Directory ( requires convert from Imagemagick)
Shutdown (system shutdown, restart and logout)
the shutdown -H now closed system
init 0 Close system
telinit 0 Close system
shutdown -h hours: minutes & shutdown of the system time
shutdown -c cancel shutdown of the system time
shutdown -r now reboot
reboot reboot
logout Logs
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 '/ file home / user1 'searches with' .bin 'end of 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 searches created or modified file in 10 days
. find / -name \ * rpm -exec chmod 755 '{}' \; search files ending in '.rpm' and define permissions
find / -xdev -name \ * .rpm search files ending in '.rpm', ignoring the CDROM, pen-drive and other removable devices
locate \ * ps find files with '.ps' ending - first run 'updatedb' command
whereis halt show a binary file, the position of the source or man
which halt show full path of a binary executable file or
mount a file system
mount / dev / hda2 / mnt / hda2 mount a disk called hda2 - determining the directory '/ mnt / hda2' already exists
umount / dev / hda2 unloading a disk called hda2 - start mount point ' / Mnt / hda2 'exit
fuser -km / mnt / hda2 force umount when the device is busy
umount -n / mnt / hda2 run umount without writing / etc / mtab file - if the file is read-only or very useful when the disk is full
mount / dev / fd0 / mnt / floppy mount a floppy disk
mount / dev / cdrom / mnt / cdrom mount a cdrom or dvdrom
Mount / dev / HDC / mnt / cdrecorder or mount a cdrw dvdrom
Mount / dev / HDB / mnt / cdrecorder or mount a cdrw dvdrom
Mount -o Loop file.iso / mnt / cdrom mount a file or ISO image
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
control on disk space
df -h display has been mounted partition list
ls -lSr | more aligned to the size of the file and directory
du -sh dir1 estimate disk space directory 'dir1' already used '
du -sk * | the Sort -rn capacity to turn the display size based on the size of files and directories
rpm -q -a --qf '% 10 { SIZE} t% {NAME} n' | sort -k1,1n sequentially displayed by size space (fedora, redhat based system) installed rpm packages used
dpkg -query -W -f = '$ {installed -size; 10} t $ {package} n' | sort -k1,1n display space by size (ubuntu, debian based system) installed deb packages used
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 syntax correction as well as existing users
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
file permissions - using the "+" to set permissions, use "-" is used to cancel
ls -lh permission to display the
ls / tmp | pr -T5 -W $ cOLUMNS divide terminal into 5 columns will show
everyone chmod ugo + rwx directory1 set directory (u), group (g) and other people (o) to read (r), write (w) and execute (x) permission
chmod go-rwx directory1 delete a group (g) and others (o) implementation of read and write access to a directory
user1 file1 change a chown all file attributes
chown -R user1 directory1 change all attributes of a directory and simultaneously change the properties of all files in the directory change
group chgrp group1 file1 file changes
chown user1: group1 file1 changes and group ownership of a file
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 - the user running the file and are each assigned to the same owner permissions
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 the directory
chmod gs / home / public disable SGID bit on a directory
allows only the legitimate owner delete files - chmod o + t / home / public set a STIKY bit file
chmod ot / home / public disable a catalog of STIKY bit
special attributes of the file - using the "+" to set permissions, "-" is used to cancel
chattr + a file1 append mode allows only read or write files
chattr + c file1 file by the kernel allows this compression / decompression automatically
chattr + d file1 file system backup is performed when, 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 Once the application of this document have been written, 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 attributes
packaged and compressed files
bunzip2 file1.bz2 decompression called 'file1.bz2' file
compression called bzip2 file1 'file1' files
gunzip file1.gz unzip a call 'file1.gz' file
gzip file1 compress called 'file1'
rar a file1.rar test_file create called 'file1.rar' package
rar a file1.rar file1 file2 dir1 while compressing 'file1', 'file2', and directory 'dir1'
rar X file1.rar packet extracting rar
unrar x file1. rar extract the rar package
tar -cvf archive.tar file1 create a uncompressed tarball
tar -cvf archive.tar file1 file2 dir1 create a containing '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 compressed format bzip2
tar -jxvf archive.tar.bz2 extracting archive a bzip2 format of
tar -cvfz archive.tar.gz dir1 create a compressed gzip format of
tar -zxvf 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 at the same time compressed into a compressed zip format
unzip file1.zip decompressing a compressed zip format
RPM package - (Fedora, Redhat and similar systems)
rpm rpm -ivh package.rpm mounting a package
rpm -ivh --nodeeps package.rpm rpm package and a mounting ignoring dependencies
rpm -U package.rpm rpm package update a profile without changing its
rpm -F update a determined rpm package installed package.rpm
rpm -e package_name.rpm remove a rpm package
rpm -qa displays all installed rpm package
rpm -qa | grep httpd show all the names included "httpd" word rpm package
rpm -qi package_name obtain a special information package installed
rpm -qg "System Environment / Daemons" show rpm packages of a component
rpm -ql package_name display a list of files already installed rpm package provided
rpm -qc package_name displays a list of configuration files installed rpm package provided
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 script displayed in l / remove during 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 --extract --make-directories * bin * rpm package from a running executable
rpm -ivh / usr / src / redhat / RPMS / `arch` / package.rpm install a package built from a rpm source
rpmbuild --rebuild package_name.src.rpm from a source to build a rpm package rpm
view file contents
content cat file1 view forward from the first byte of the file
tac file1 from the last Reverse line began to view the contents of a file
more file1 view the contents of a file along
less file1 similar to 'more' command, but it allows the operation of the forward and reverse operation in the same file,
the first two lines of a file head file1 view -2
tail -2 file1 view of a document the last two lines
tail -f / var / log / messages view in real time is added to the contents of a file in
text processing
cat file1 file2 ... | command <> file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT
cat file1 | command (sed, grep , awk, grep, etc ...)> result.txt merge a text file detailed description, and the introduction writes a new file
cat file1 | command (sed, grep , awk, grep, etc ...) >> result.txt a combined detailed description text file, and writes a profile existing file
grep Aug / var / log / messages in file '/ var / log / messages' in Find keyword "Aug"
grep-Aug ^ / var / log / messages in file '/ var / log / messages' to find "Aug" words beginning
grep [0-9] / var / log / messages select' / var / log / messages' File all lines that contain numbers
grep Aug -R / var / log / * Search the directory '/ var / log' directory and subsequent string "-Aug"
Sed 'S / stringa1 / stringa2 / G' of example.txt in example.txt " string1 "replaced" string2 "
Sed '/ ^ $ / D' example.txt deleted from any blank row in example.txt
sed '/ * # / d; / ^ $ / d' example.txt file from example.txt remove all comments and blank lines
echo 'esempio' | tr '[ : lower:]' '[: upper:]' merge cell contents up and down
sed -e '1d' result.txt excluded from the first file example.txt row
row sed -n '/ stringa1 / p' view only contains the words "string1" the
sed -e 's / * $ // ' example.txt end of each row to delete blank character
sed -e 's / stringa1 // g 'example.txt removed from the document only the words "string1" and retain all remaining
sed -n' 1,5p; 5q 'example.txt view from the first to the fifth row of content
sed -n' 5p; 5q 'example . See txt line. 5
Sed -e ' s / 00 * / 0 / g ' example.txt replaced with a single zero zero plurality of
rows cat -n file1 file designated
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} 'view the first and third column line
paste file1 file2 merging two files or the contents of two columns
paste -d' + 'file1 file2 merging contents of two files or two columns, with the intermediate "+" to distinguish
sort file1 file2 sort contents of two files
sort file1 file2 | uniq of two files and set (only one copy of duplicate rows)
sort file1 file2 | uniq -u files by viewing only unique line
sort file1 file2 | uniq -d out two intersection of files (leaving only two files exist in the file)
content comm -1 file1 file2 compare two files to delete only content 'file1' contained
comm -2 file1 file2 compare two files is only It deleted included in the content 'file2'
COMM comparing two content -3 file1 file2 file delete only portions of both files
character sets and file format conversion
dos2unix filedos.txt fileunix.txt the format is converted from a text file into MSDOS UNIX
unix2dos fileunix.t xt filedos.
recode ..HTML <page.txt> page.html convert a text file into HTML
Recode -l | More show all allow conversion format
file system analysis
badblocks -v / dev / bad blocks on the magnetic disk check hda1 hda1
the fsck / integrity dev / hda1 repair / check disk hda1 linux file system
integrity fsck.ext2 / dev / hda1 repair / check disk hda1 ext2 file system
e2fsck / dev / hda1 complete the repair / inspection ext2 filesystem on disk hda1 sexual
integrity e2fsck -j / dev / hda1 repair / check disk hda1 ext3 file system
integrity fsck.ext3 / dev / hda1 repair / check disk hda1 ext3 file system
fsck.vfat / dev / hda1 repair / check hda1 the integrity of the file system on the disk fat
fsck.msdos / dev / hda1 repair / check on disk hda1 dos file system integrity
on dosfsck / dev / hda1 repair / check hda1 dos disk file system integrity
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
SWAP file system
mkswap / dev / hda3 create a swap file system
swapon / dev / hda3 enable a new swap file system
swapon / dev / hda2 / dev / hdb3 enable the two swap partitions