Common commands in Ubuntu 12.04 64-bit

Source: Internet
Author: User
Tags exit empty parent directory linux

The following command is passed under Ubuntu 12.04 64.

In Linux everything is a file, including folders is a special file, and even devices are files.

View the current system version

Cat/proc/version 
#Linux version 3.2.0-29-generic (buildd@allspice) (gcc version 4.6.3 (Ubuntu/linaro 4.6.3-1UBUNTU5) #46-ubuntu SMP Fri 17:03:23 UTC 
#Linux web uname-a #46 3.2.0-29-generic SMP Fri 17:03:23 UTC x86_64 x86_64 x86_64 gnu/linux 
     
cat/etc/issue 
#Ubuntu 12.04.1 LTS \ n \l

Shows the path of a command

Which AddUser 
     
/usr/sbin/adduser 
     
which groups/usr/sbin/groups which 
     
     
ls 
/bin/ls

View the users online

W.H.O.

Displays the current user's account number

WhoAmI

Reboot

Reboot

Shutdown

Shutdown

View Current User

Users

View the group where the current user is located

Groups

Modify the current user's password

passwd

To modify a user's User1 password

passwd user1

Toggle User User1

Su user1

Switch to root user

Su

Create a table of contents

mkdir Dir1

Delete Directory

RmDir Dir1

Switching directories

Cd

Return to Parent Directory

Cd..

New File File1

Touch File1

New and edit File File1

VI file1

deleting files

Rm

Show file contents

Cat File1

More File1

Less file1

Cat also has the ability to create a new file and save the input to a file at the same time

Cat >> File1

This paper url:http://www.bianceng.cn/os/linux/201410/45615.htm

Typing the above command, you can start to enter the contents of the file, you can also change lines, if the input is finished, press the ctrl+d at the same time, will end the input, and the content just entered to save the file.

Show front 10 lines of file

Parameters can be specified to show n rows before

Head File1

Display the last 10 lines of a file

Parameters can be specified to show the following n rows

Tail File1

List all files in the "Home" directory

Ls/home

List all files in the "Home" directory, excluding hidden files

Displays the permissions, owner, size, and last update time of the file

Ls-l/home

Lists all of the files in the "Home" directory, including hidden files, in the form of a list. The opening file is the hidden file.

Displays the file type, permissions, owner, owner's user group, size, last update time

Ls-al/home

Change the owner of a file

Chown User1:group1 File1

Change permissions for a file

A all users, + add permissions, rwx read, write, execute permissions

chmod a+rwx File1

Display a description of a command

Description includes usage and interpretation

Mans Cat

Displays the parameters and basic usage of a command

Add--help behind the command

Cat--help

Most of the time, if you don't know the exact usage of a command, or what parameters it means, you can use the two commands above to view it.

Add User User1

AddUser user1

Add User Group

AddGroup group1

Initializes a user to a group while adding a user

AddUser--ingroup group1 User11

Add an existing user to an existing group

AddUser User12 group1

Cut command

The Cut command allows you to do some separation of files, parsing, and processing files based on rows. Separate each line of the file by law, and get some of the contents.

For example, I want to get the login account of all the users in the system, we all know that there is a/etc/passwd file in the system, but there are other contents as well.

Cut-d:-f1/etc/passwd

What do you do with the above order? The-D argument is used to indicate a separator, because each row of the passwd file is separated by a colon, and the-f parameter indicates the field you want, indicating the first field, the Login account field, and the location of the file.

If you want a few fields, you can use-f1-3 to represent the first to the third field, and the-f1,3 to represent the first and third fields.

cut-d:-f1/etc/passwd >>/tmp/users

Using the above command, the result of the cut command is saved to the/tmp/users file.

WC command

The WC command is used to count the number of rows, characters, words, and bytes of the file.

root@web:/home# wc-l file1 
4613 file1 
root@web:/home# wc-c file1 
221987 file1 root@web:/home# wc-c fil 
E1 
221987 file1 
root@web:/home# wc-m file1 
220166 
file1 
root@web:/home# wc-l file1 393 file1 
root@web:/home# wc-w file1 
11902 file1

VI Editor

VI NewFile

Two modes: Command mode and insert mode.

First into the command mode, press A,i,o to enter the insert mode, in the bottom line display-insert-, the representative can now edit the file. If you want to go back to command mode, you need to press the ESC key.

Press A will insert at the beginning of the next character, press I to start the insertion at the current position, and press O to begin inserting from the new line.

Commands that are commonly used in command mode include

: W newfile2, Save as Newfile2.
: Wq, save and exit.
: q!, force exit, do not save.
: W, save only, do not exit.

GG, back to the first character of the file.
G, to reach the last character of the file.
DD, deletes the current line where the cursor is located.

x, deletes a character at the position of the cursor.

X, deletes a character before the position of the cursor.
H, move one character to the left.
J, move one character down.
K, move one character up.
L, move one character to the right.
Ctrl+b, move one page back.
Ctrl+f, move one page forward.
Ctrl+u, move back half a page.
Ctrl+d, move the half page forward.
W, skip to the beginning of the next word.
E, skip to the end of the next word.
$, move to the end of the line where the cursor is located.
0, move to the beginning of the line where the cursor is located.
U,undo operation, which can be used after misoperation.
: Set NU, which lists the line numbers before each line.
: 100, you can jump straight to line 100th.

GGDG, empty the contents of the file.

At some point, the contents of the file need to be emptied without deleting the file. Analogy some log files (log.txt); the commands under Linux are:

Empty the contents of the file Log.txt.

True > Log.txt

Query Command Locate

Locate is the query index, in the index to query whether there are matching criteria for files, which requires indexing first, the system automatically indexing every day.

You can also build indexes by manually executing updatedb.

UpdateDB 
     
Locate File1

Query command find

Find is a real-time search, so the query consumes longer than locate.

Find/-name "File1"

Query command grep

grep's Query object is the contents of the file, which matches the conditions in the behavior unit.

Grep-c "using" file1

The number of file1 in the query using the.

grep is a powerful text search tool that uses regular expressions to search for matching text for output.

redirect

redirect Hello to the Readme file

echo "Hello" > Readme

Append the 1,2,3 redirect to the Readme file with an append of two > symbols.

echo "1,2,3" >> Readme

Pipeline

Use the output of the previous command as input to the next command, | symbolic link two commands.

user1@web:~$ CAT/ETC/PASSWD | Cut-d:-f1 
root 
daemon 
bin 
sys 
sync 
Games 
man 
LP 
Mail 
news 
UUCP 
proxy 
www-data 
backup 
list 
IRC 
gnats 
Nobody 
libuuid 
syslog 
Messagebus 
sshd 
ntp 
user1 
user11 
user12 
MySQL

/etc/passwd file

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.