1.1 Shutdown
Immediately shut down
shutdown -h now
init 0
Haiti
Note: The above can be done in three ways shutdown NO
Shut down the system at predetermined time
shutdown -h hours:minutes
Cancel shutdown of the system time
shutdown -c
2.1 directory operations
Enter '/ home' directory
cd / home
Go back one level
cd ..
Go to home directory (user to user, for example, in practice, use your existing user systems)
cd ~user1
Returns the directory where the last
cd -
Displays the current working directory
pwd
View files in the directory
ls
Show details of files and directories
ls -l
Show hidden files (a little in front of the file name.)
ls -a
Creating a 'ych1' directory is called
mkdir ych1
Delete called 'file1' files
rm file1 -f
Delete called 'ych1' directory
rmdir ych1
Delete called 'ych1' directory and delete its contents
rm -rf ych1
At the same time remove two directories and their contents
rm -rf ych1 ych2
Rename / move a directory
mv dir1 new_dir
2.2 File Operations
Copy a file (copy the contents of file1 to file2)
cp file1 file2
Copy all files in a directory under the current working directory
cp dir / *.
Copy a directory
cp -a dir1 dir2
Create a soft link to a file or directory
In -s file1 Ink1
Create a link to the file or directory is physically connected (hardwired)
In file1 Ink1
File Search 2.3
From '/' began to enter the root file system to search for the file name of the file file1
find / -name file1
Search belonging to the user 'root' files and directories
find / -user root
File in the directory '/ home / user1' end with the search '.bin' of
find /home/user1 -name \*.bin
From the root directory of the file to start the search over the past 100 days has not been used
find / -type f -atime +100
Created or modified within 10 days to start the search from the root directory of the file
find / -type f -mtime -10
Display the full path to a binary executable file
which halt
2.4 file system mount
Mount a cdrom or dvdrom
mount /dev/cdrom /mnt/cdrom
Mounting a file or image file ISO
mount -o loop file.iso /mnt/cdrom
2.5 view file contents
The first line starts from the content view files (file1 is the file name)
cat file1
View the contents of a file in reverse, starting from the last row
tac file1
View the contents of a file, support for page down, hit Enter to flip down
more file1
Similar to the 'more' command, supports up / down, up and down keys on the keyboard page
less file1
The first two lines to view a file, file1 is the file you want to view
head -2 file1
View last two lines of a file
tail -2 file1
Live View is added to the contents of a file
tail -f/var/log/messages
Note: After executing the command, message in this file has been opened, if the file has
Update, it will print to the screen in real time
2.6 Text File
File1 output lines included in the character string root
cat file1 | gerp root
In the document '/ var / log / messages' comprises Find 'root' of row Image
grep root / var / log / messages
In the document '/ var / log / messages' search comprises 'root' command string
grip root -R / var / log / *
In example.txt the 'string' replaced 'string2'
sed ‘s/stringa1/stringa2/g’ example.txt
Delete the first line from the file example.txt
sed -e '1d' result.txt
View example.txt file contains only 'string1' row
sed -n '/string/p' example.txt
Example.txt view files in the first row to the fifth row of content
sed -n ‘1,5p’ example.txt
And the set of two files (only one copy of the duplicate rows)
sort file1 file2 | uniq
Files by viewing only unique line
sort file1 file | uniq -u