Linux command Refresher (2)

Source: Internet
Author: User
Tags system log time and date reverse dns

emptying files with redirects

>the contents of filename =>filename are emptied

Command Help

$ man command

Query the description document for command commands

$ man-k keyword

Query keywords

$Info command

A more detailed description of the document

$whatis command

Brief description

$which command

The path to the binary file where command

$whereis command

All the command in the search path

Here's an example of a command (binary file). For example, man can also be used to query system functions, configuration files, and so on.

User

$Finger username

Display user username information

$ who

Show current logged in user

$ who am I

An interesting usage.

$Write username

Send message to User (end input with EOF)

$su

Become the root user

$sudo command

Execute AS Root user

$passwd

Change Password

SHELL (BASH)

$ History

Show command history under current shell

$alias

Show all commands for the nickname

$alias new_command= 'command'

Call command not New_command

$env

Show all environment variables

$Export var=Value

Set environment variable var to value

$Expr 1 + 1

Calculate the

File system

$du -sh dir

Folder size,-H human-readable units,-s only show summary

$Find . -name filename

Start with the current path and look down for the file filename

$Locate string

Find a path that contains a string

$UpdateDB

Unlike find ,Locate is not a real-time lookup. You need to update the database to get the latest information.

$Ln -s filename path

Create a soft link to the file filename in the path location

$pwd

Show current Path

$CD path

Change the current working path to Path

$CD -

Change the current path to the previous path

File

$Touch filename

If the file does not exist, create a blank file, and if the file exists, update the file read and modify times.

$RM filename

deleting files

$cp file1 file2

Copy file1 to file2

$ls -l Path

displaying file and file-related information

$mkdir dir

Create Dir folder

$mkdir -P Path

Recursively creating paths for all folders on path

$rmdir dir

To delete the dir folder,dir must be an empty folder.

$RM -R dir

Delete the dir folder and all files it contains

$rm-I. Dir

When the Dir folder is deleted, a dialog is prompt

$rm-I. Dir

Prompt once before removing more than three files, or when removing recursively. Less instrusive than-i, while still giving protection against most mistakes

$rm-F Dir

Ignore nonexistent files, never prompt

$file filename

Type description for file filename

$chown username:groupname filename

Change file ownership will be OwneR, owning group

$chmod 755 filename

Change the file's permissions to 755:owner r+w+x, Group:r+x, others:r+x

$od -c filename

displaying files in ASCII characters

File display

$Cat filename

Show Files
$Cat file1 file2

Connection display file1 and File2

$Head -1 filename

Show the first line of the file

$Tail -5 filename

Show file bottom line fifth

$diff file1 file2

Shows the difference between file1 and file2

$Sort filename

Sorts the rows in the file and displays

$Sort -f filename

When sorting, do not consider case

$Sort -u filename

sorting, and removing duplicate rows

$uniq filename

Displays the rows that are not duplicated in the file filename (same content but not adjacent rows, not duplicates)

$WC filename

The number of characters, words, and lines in the statistics file

$WC -l filename

Number of rows in the statistics file

Text

$echo string

Display string

$echo string | Cut -c5-7

5th to 7th columns of truncated text

$echo stringgrep Regex

To display a row that contains a regular expression regex

$echo string | grep -o regex

Displays substrings that conform to the regular Regrex

Time and date

$Date

Current date Time

$Date + "%y-%m-%d_%t"

Display datetime in YYYY-MM-DD_HH:MM:SS format (format can refer to $man date)

$Date --date= "1999-01-03 05:30:00"

Shows the datetime from 1900-01-03 05:30:00 backwards 100 days

$Sleep 300

Sleep 300 seconds

Process

$Top

Show process information and update in real time

$PS

Shows the process under the current shell

$PS -lu username

Show the process of user username

$PS -AJX

Show all processes in a more complete format

$Kill PID

Kill PID (PID is process ID)

$Kill %job

Kill Job (Job number)

$lsof -u username

Files opened by the user username process

$DMESG

Show System Log

$ time a.out

Test the run time of the a.out

Hardware

$uname -A

Display System Information

$DF -LH

Display the usage status of all hard drives

$Mount

Show all hard disk partition mounts

$Mount partition path

Hang on partition path

$umount partition

Uninstalling partition

$sudo fdisk -L

Show All partitions

$sudo fdisk device

Create a partitioned table for device (such as/DEV/SDC). After entering, select N, p, W

$sudo mkfs -t ext3 partition

Format Partition patition(e.g./DEV/SDC1)

Modify the/etc/fstab to mount the partition automatically. Add Rows:

/DEV/SDC1 Path (mount point) ext3 defaults 0 0

$Arch

Display schema

$Cat /proc/cpuinfo

displaying CPU information

$Cat /proc/meminfo

Display memory Information

$cat/etc/issue

Show Fedora Version

$ Free

Show Memory usage

$pagesize

Display memory page size (in KByte)

Internet

$ifconfig

Displays the network interface and the corresponding IP address. Ifconfig can be used to set the network interface

$ifup eth0

Running the eth0 interface

$ifdown eth0

Close the eth0 interface

$Iwconfig

Show Wireless network interface

$Route

Displays the route table. The route can also be used to modify the routing table

$netstat

Displays the current network connection status

$Ping IP

Send ping packets to address IP

$traceroute IP

Probing the route path to address IP

$dhclient

Send DHCP requests to the DHCP host for IP addresses and other setup information.

$host domain

DNS query, look for the domain name IP corresponding to

$Host IP

Reverse DNS Query

$wget URL

Use wget to download the resources that the URL points to

$wget -M url

Image download

SSH login and file transfer

$ssh ID@host

SSH login remote server host,ID is user name.

$sftp ID@host

Login Server host,ID is user name. After the sftp login, you can use the following command to further the operation:

Get filename # download file

put filename # uploading files

LS # Lists all files for the current path on the host

CD # Change the current path on host

lls # Lists all files for the current path on the local host

LCD # Change the current path on the local host

$SCP localpath ID@host:path

Upload the file that the local LocalPath points to to the path path of the remote host

$SCP -R ID@site:path localpath

In the SSH protocol, traverse The entire file system in the download path path, to the local localpath

Compression and archiving

$zip file.zip file1 file2

Compress file1 and file2 to file.zip

$Unzip file.zip

Decompression File.zip

$gzip -c filename > file.gz

Compress file filename to file.gz

$gunzip file.gz

Unzip the file.gz . zip file

$tar -cf file.tar file1 file2

Create a tar archive

$tar -zcvf file.tar file1 file2

Create a tar archive and compress

$tar -xf File.tar

Release the TAR Archive

$tar -zxvf file.tar.gz

$tar-JXVF file.tar.bz

Unzip and release the TAR Archive

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.