Chapter linux command unknown

File and directory commands

cd / home into the home directory '
CD .. go back one level

pwd Displays the current working directory

ls view files in a directory
ls -l show details of files and directories (can be abbreviated as ll), with the specific file name may
display hidden files ls -a

echo "Your are the best boy. "> book.txt generate files with simple content of
touch creates an empty file
touch aa.txt

mkdir dir1 create one called 'dir1' directory '
mkdir dir1 dir2 create two directories simultaneously
mkdir-p / dir1 / dir2 batch create multi-level directory

rm -f file1 delete called 'file1' files, -f delete files without asking
rmdir dir1 delete called 'dir1' empty directory ', you can not delete a non-empty directory
rm -rf dir1 delete the directory and its files, and can delete non-empty directory. -rf parameter represents the recursive force delete

mv rename / move files
mv test1.txt test2.txt be renamed test1.txt test2.txt (no test2.txt file in the current directory, rename)
mv test1.txt mydoc1 test1.txt moved to the directory mydoc1 (current directory exists mydoc1 directory, move)
Music Videos the test1.txt mydoc3 test3.txt was moved into a plurality of files in the directory mydoc3
present MYDOC2 mv mydoc1 mydoc2 directory in the current directory, the mobile directory to MYDOC2 mydoc1 directory
mv mydoc7 mydoc8 mydoc8 directory does not exist in the current directory, therefore mydoc7 rename mydoc8

cp file1 dir1 copy a file, copy file1 dir1 to the next folder, the file contents remain unchanged

Look at the file command
cat file1 forward file1 view the contents of the file (one-off display file) 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 document, page view display a full pause, then press the spacebar
to continue to display the next screen display is stopped by Q
less file1 similar to 'more' command, the difference is less with the arrow keys allow the user to look back, exit with z + Ctrl
du -h filename to view the files take up disk space
for all the disk space occupied by directories under du -h dirname view directory, use the absolute path here / Home / ccc
grep to find the specified string in the specified text file , it is a powerful text
grep this is new2.txt, including the return new2.txt text string "this is" line.

File Search command
find / -name filename from '/' root folder find the file named filename (after the note / spaces, absolute path)
the Find ./ -name filename to query the current directory under the file name for the file filename (relative path)

Packaged and compressed files command

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

Compression: bzip2 FileName
extracting 1: bzip2 -d FileName.bz2
extracting 2: bunzip2 FileName.bz2

Compression: gzipFileName
decompression 1: gunzip FileName.gz
decompression 2: gzip -d FileName.gz after decompression, the original compressed file is deleted

The tar -cvf newpackage.tar file1 file1 and packaged from the package name for package.tar, a packaged file
tar -xvf package.tar unpack
tar -xvf package.tar -C / home / ccc / mydoc1 to release the compressed packet / at home / ccc / mydoc1 directory
tar -jcvf package.tar.bz2 dir1 create a bzip2 format archive
tar -jxvf package.tar.bz2 decompress a bzip2 format archive
tar -zcvf package.tar.gz dir1 create a gzip compressed format
tar -zxvf package.tar.gz decompressing a compressed gzip format

View disk and memory space command
du show disk space each file and directory
du-H File
df show disk file free space
df -h
as Free and display systems use free memory case
free-m

Network commands
ifconfig view the local IP address
ping each IP test from the machine to the other network connectivity
ping 192.168.1.11

System Management Command
Top dynamically displays the current system in the process of consuming the most resources (cpu / memory, etc.)
Kill -9 pid forced to kill the process
Clear to clear the screen - Turn to the next
reset clear the screen --- clear all history command
ps with to show the current status of the process
Ps -ef | grep Tomcat
Ps -aux
shutdown reboot command
reboot
vIM editor Introduction
: q exit vi
: WQ save and exit vim, press the Enter key (Alternatively, you can save: quit after w: q)
:! q forced to quit without saving
: set number is displayed in the edit line numbers
: set nonumber not display line numbers to edit the file
: e filename opens the file in the current directory
: e / user / local / filename to open the absolute path file
: w filename to save the current contents of the file named filename (generally the first case came in vim),
then press: wq to save and exit

vim + n filename document open in a conventional manner, positioning the n-th row

User Account Management
useraddnewuser create a new user, the default in your home directory
passwdnewuser carriage return, set a password for the new user newuser, password is not echoed
userdel -r DDD delete user DDD, their home directories and files be deleted
groupadd -g 550 mygroup1 create a new group, this time to produce a group ID (GID) in the / etc / group file
is the project 550
groupdel group1 group1 delete a user group

File permissions management

Chmod 777 -R / opt to the highest authority of all files in / opt and its subdirectories (read, write, execute)

Supplementary follows:
Three basic permissions
R Read access
W Write permission
X execute permissions

Change the operating authority
chmod g belongs to the main group of users [u o other users a genus all users] [+ plus permission - permission to minus = plus permission will also delete the original permission] [rwx] file or directory name

The W + File chmodg
-R & lt subdirectories below do the same operation authority
may be represented by numbers 777 File permissions as the chmod
R & lt W 2 X 1 4
To rwx attribute is 4 + 2 + 1 = 7;
To attribute rw- the 4 + 2 = 6;
To the attributes rx 1 = 4 + 5;

First, copy the file to the machine on a remote server

scp /home/news.txt [email protected]:/etc/ccc

absolute path / home / local file
news.txt to be copied to a local file on the server
root login to a remote server via root user (you can also use other user of equivalent authority)
ip address 192.168.6.12 remote server (you can also use domain name or machine name)
/ etc / ccc copy the file to a local path is located on a remote server

Guess you like

Origin www.cnblogs.com/king8/p/11481157.html