Ubuntu Common Command Rollup

Source: Internet
Author: User
Tags chmod diff echo command memory usage mkdir parent directory rar touch command

1. get Ubuntu version number :/etc/issue or Lsb_release-a

2. view Ubuntu system digits : Uname-ar or getconf long_bit

3. View the processor architecture of the Ubuntu machine , resulting in i686 or X86_64:arch or uname-m

4. display the contents of the current directory (catalog list)(if sorted by file change chronological order, you can use LS-LT): LS

5. display the current directory of the file details , including read and write permissions, file size, file generation date, etc. (if you want to order according to the time of change, you need to add-t parameter, ll-t or Ll-t |tac, the latter for the latest modified time in the last): LL

6. change the current working directory location (if you enter the system root, you can use CD/): CD Directory_name, if there are spaces in the folder, you need to enclose in quotation marks, such as enter the directory named a b directory, then: CD "a B"

7. deletes the specified file in the current directory , such as deleting all files for. xxx (for linked files, only deletes the link, the original file remains unchanged, and if you do not use the-r option, RM does not delete the directory; If you want to delete it, you can use the-I option, such as Rm-i XXX): RM *.xxx

8. Delete Empty directory , a directory must be empty before the deletion, delete a directory must also have the Write permission on the parent directory: rmdir xxx

9. Move the file (if the file Xx.yy moved to the directory TT, the MV Xx.yy TT) or rename the file (if the file name xx.yy to AA.BB, then MV Xx.yy aa.bb): MV source file or directory Destination file or directory

Copy Files (can have multiple files at the same time) or directory to the specified directory (if the directory AA copy to the BB directory, then: Cp-a AA bb): CP source file or source directory destination directory

One. Create a new directory that requires the user who created the directory to have write permission in the current directory, and the specified directory name cannot be an existing directory in the current directory (if you create a directory with 777 permissions, you can use mkdir-m 777 filename): mkdir filen Ame

View a detailed description of an instruction , such as view RM directives: Man RM

Create a static library , such as using all. o files in the current directory to create libxx.a static libraries: Ar-r LIBXX.A *.O

Create a dynamic library , such as using all. o files in the current directory to create a libxx.so dynamic library (if two of the. cpp files in a different directory generate a dynamic library directly; gcc-shared/home/spring/gdbtest/src/ Add/add.cpp/home/spring/gdbtest/src/subtract/subtract.cpp-o libtest.so) (if b1.a,b2 from a static library, A directly generates dynamic library b.so, the corresponding command is: GCC-SHARED-FPIC-WL,--whole-archive b1.a b2.a-wl,--no-whole-archive-o b.so): Gcc-shared–o Lib Xx.so *.O

Look at the current path (full path): pwd

You need to prompt permission to execute the command , if you are not the root, then some of the commands to do some operations are sometimes not allowed, at this time can be in front of the command plus Sudo:sudo

See if the static library contains a function , such as seeing if there is a fun1 function in the XX.A static library (or you can view all of the functions contained in a library, such as NM xx.a >fun.txt): NM xx.a | grep fun1

See if a dynamic library contains a function , such as seeing if there is a fun2 function in the yy.so dynamic library (or you can view all of the included functions for a library, such as NM yy.so > Info.txt): NM yy.so | grep fun2

If you export only the defined symbols, add the "-d" option, such as nm-d yy.so | grep fun2

View Cpuinfo Related information : Cat/proc/cpuinfo

Show system date : Date

The CAL command is used to view Gregorian calendar calendars , which can be viewed in the specified year, such as Cal-y 2013, or in the current month, directly with CALs without any arguments.

shut down the system (if it is not root, shutdown before you need to add sudo): Shutdown-h now

Reboot the system (if not root, then shutdown before adding sudo): shutdown-r now

Share a directory command with Windows , such as the shared directory as Test (http://download.csdn.net/detail/jiaoxiaogu/7309181): cd/mnt/hgfs/test

create a soft connection to a file or directory (when we need to use the same file in a different directory, we don't need to put a file in every directory that needs to be the same, we just put it in a fixed directory, It can then be used in the other directory with the ln command link (link) and it will not have to be duplicated to occupy disk space. Format, ln-s the source file destination file. Files remain synchronized. Directories can only create soft links, directory creation links must use absolute paths, modifying files in the linked target directory will change synchronously in the source file directory. For example, create a new directory for the source directory/home/spring/aa/usr/local/aa:ln-s/HOME/SPRING/AA/USR/LOCAL/AA

Change the date and time of a file or directory , including the access time and the time of change (if there are two files A.B,C.E, modify the date of the C.E file to the a.b date, Touch a.b C.E), or create a new file that does not exist ( If the existing aa.x file is newly built into a bb.y file (bb.y file is not originally present), and keep the contents of the aa.x file, the creation of modified time consistent, then touch aa.x bb.y): Contact source file name destination file name

Each file has a timestamp, which includes the access time and the modification time, and the Touch command is used to modify the file's access time and modification time. If the timestamp of the file a.txt is changed to the current time, execute: $ touch a.txt

Displays the contents of the file (cat Aa.txt if the Aa.txt file content is displayed), or joins several files to display: Cat filename

Add the output file contents automatically to the line number : NL filename

to display the contents of a file in one page, press the SPACEBAR (space) to display the next page; press the B key to go back (back) a page to display; press Q to exit More:more filename

page display file content , similar to more, but more powerful than more; Press Q key to exit less; If you search for a string xxx in a file, you can use/xxx to do so; display the line number of each row by adding the-n parameter: less parameter filename

used to display the beginning of a file : Head filename

used to display the end content of a file : tail filename

To see if a system command exists or to view the location of an executable file, if you look for the location of the LS command, which LS, returns/BIN/LS, and if the command (or the execution file) is not found, no results are returned: which COMMANDN Ame

Find all Files in the current directory where the filename suffix is txt (find/-name "*.txt" If you look for it from the system root); If you look for it from your $home directory, find ~-name "*.txt"; in the/etc directory  Lookup, Find/etc-name "*.txt"; to find the file name in the current directory starting with a lowercase letter, and finally to 4 to 9 plus. Log end of file;  –name "[A-z]*[4-9].log"): Find. -name "*.txt"

in the current directory, look for the specified keyword "AB" contained in all files in this directory , then execute: $ find. -type f-print-exec grep ab {} \;

The

34.       chmod command is used to change access rights for Linux system files or directories . Each file and directory in a Linux system has access permission to determine who can access and manipulate files and directories in any way. File or directory access is divided into read-only, write-only, and executable three kinds. There are three different types of users who can access files or directories, file owners (typically the creator of files), the same group of users, and other users. Each file or directory has three sets of access rights, each of which is represented by three bits, which are the read, write, and execute permissions of the owner of the file, as well as the read, write, and execute permissions of the user who is the owner of the same group When you display the details of a file or directory with the ls -l command, the leftmost column is the file's access rights. There are 10 positions in the first column, and the first character specifies the file type. In the usual sense, a directory is also a file. If the first character is a horizontal line, it represents a file that is not a directory. If it is D, the representation is a directory. From the second character to the tenth a total of 9 characters, 3 characters a group, respectively, representing 3 groups of users of the file or directory permissions. Permission characters use horizontal lines to represent a null license, R for read-only, W for write, and X for executable. Once you have determined the access rights of a file, users can use the chmod command to reset different access rights. Permission code: r: Read permission, with the number 4; w: Write permission, indicated by the number 2; x: Execute permissions, with a number of 1;-: Delete permissions, with number 0; s: Special permissions. If you add readable writable executable permissions to the directory test and all files of its subdirectories, then:chmod -r 777  test

35. The tar command can be used to compress, decompress, package, unpack, etc. Packaging refers to a large pile of files or directories into a total file, compression is a large file through some compression algorithm into a small file. The packages used in the TAR program are often referred to as tar packets, and the TAR package file commands are usually terminated with a. Tar. After the tar package is generated, it can be compressed with another program. Common parameters:-C: Create a new compressed file;-X: Extracts files from compressed files;-Z: Supports gzip extract files;-j: Supports bzip2 decompression files;-Z: Supports compress decompression files;-V: Displays the operation process;-F: Specifies the compressed file. For example, there is a directory test1, which is packaged as: Tar cvf test1.tar test1; If you package it and use gzip to compress it: tar zcvf est1.tar.gz test1; If the solution or decompression, then the corresponding CVF and ZCVF into XVF and ZXVF can be, such as the test2.tar.gz uncompressed, then: Tar xvf est2.tar.gz, will be in the current directory to generate a test2 file.

To view the size of the space used by a file or directory disk , you can use the Du command, such as displaying the test directory size, to locate the terminal after the test directory, enter: Du-s

Diff compares the contents of a single file or directory . If you specify a file for comparison, it is only valid if you enter as a text file. Compare the similarities and differences of text files in line-by-row manner. If you specify a table of contents, the diff command compares a text file with the same name in two directories. Lists the different binaries, common subdirectories, and files that appear only in one directory. If you compare 1.txt and 2.txt Two text files, you can: Diff-c 1.txt 2.txt, the content will be different places before using the "!" Marked out.

The grep command is a powerful text- search tool . Look for Android keywords from the test.txt file: Grep-n ' Android ' Test.txt. You can also find keywords from multiple files at the same time, such as: Grep-n ' Android ' Test1.txt test2.txt

If you want to find the "AB" string for all files in the current directory: $ GREP-RN "AB" *

The WC command is used to count the number of rows, words, and bytes in the specified file and display the results to the output. such as: WC Test.txt, the output is 8 9 test.txt, of which 8 is the number of lines, 9 for the word, 10 for the number of bytes, test.txt represents the filename. If you count the number of lines of code with a suffix named frm, ASP, and BAS under the current directory, then the command is find. -name "*.frm"-or-name "*.bas"-or-name "*.asp" | Xargs wc-l > Result.txt, after executing this command, generates a result.txt file in the current directory containing the number of lines of code per file (frm/bas/asp) and the total number of lines of code.

The free command displays the idle, used physical memory and swap memory in the Linux system, and the buffer used by the kernel. For example: Free-m, the memory usage is displayed in megabytes.

41. You can use the Apt-get command to Install/update a deb package , such as installing g++, then: Apt-get install g++

c++filt Command : C + + functions will be similar after compiling on Linux systems: _zn9cbc_ean1312renderbitmaperp12cfx_dibitmapri, at first glance, does not know the original name of the function, You can use the c++filt command: c++filt _zn9cbc_ean1312renderbitmaperp12cfx_dibitmapri to display the original function name Cbc_ean13::renderbitmap (CFX_ dibitmap*&,int&)

The echo command is a built-in shell command that displays the value of a variable or prints a line of text , such as by entering the Echo $PATH to see which file directories are added to the system environment variable (the $ in front of the PATH is followed by a variable), You can write 2 to a 1.txt file by entering Echo 2 >/home/spring/1.txt

The RAR command can extract the RAR files generated under Windwos , such as Test.rar, you can perform: $rar x test.rar

The PS-EF command is used to view all processes of the Linux system , and if you want to see a process that contains a specified name, such as test, you can do so: $ ps-ef | grep test

Kill the specified process can use the KILL command, such as killing process PID 30732 process, you can execute: $ kill-9 30732, if you need to mass kill process, you can execute: $ ps aux | grep Test | awk ' {print $} ' | Xargs kill-9

Check the Linux system CPU and memory usage , you can use the top command: That is, first in the terminal Input Top command return, and then press 1

Open the display image by command : $ eog/images/a.jpg

Remote Copy Files : You can use the "SCP" command, such as passing a specified directory or file from a remote server to a locally specified directory, execute: $ scp-r xxx spring@10.0.0.66:/home/spring/yyy/; If stored in the local root directory, you can execute: $ scp-r a.jpg spring@10.0.0.66:~/; When you execute the above command, you will be required to enter the local machine password, if you do not want to enter each time, you can perform: $ Ssh-copy-id spriing@10.0.0.6 6, so the next time when the file will not have to repeatedly enter the password, if from the local file to the remote server, then execute: $ scp-r b.jpg autobuild@10.0.8.88:/home/autobuild/fbc/

view IP and MAC address : $ ifconfig

Mount Ssh-server: $ sudo apt-get install-y openssh-server

You can access the specified Ubuntu host through an SSH command, assuming you have access to the Ubuntu host named Spring, IP 10.0.1.1, and know the password for this host, then execute: SSH spring@10.0.1.1, enter, and then income this host's password can be

install Google Chromeand execute the following command:

Wget-q-o-https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add-
sudo sh-c ' echo ' Deb [Arch=amd64] http://dl.google.com/linux/chrome/deb/stable main >>/et C/apt/sources.list.d/google-chrome.list '
sudo apt-get update
sudo apt-get install google-chrome-stable

53. Resolve Pop-up dialog box "System program problem detected does you have want to the problem now?" The problem in the terminal input: $ sudo rm/var/crash/*

54. On Ubuntu to see what encoding the specified file is, you can use file commands, such as finding the encoding format for all the. cpp files under the test directory, execute: $ file Test/*.cpp

55. Install the. deb File command on Ubuntu, such as Code_1.13.0-1496940180_amd64.deb: $ sudo dpkg-i code_1.13.0-1496940180_amd64.deb

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.