! $
! $ Is a special environment variable, which represents the last string of the previous command. For example, you may:
$ Mkdir mydir $ MV mydir yourdir $ CD yourdir can be changed to: $ mkdir mydir $ MV! $ Yourdir $ CD! $
Available directly! $ Represents the last string of the Last Command executed
loongson@LOonux:~$ touch 123loongson@LOonux:~$ vim 123loongson@LOonux:~$ touch 123loongson@LOonux:~$ vim !$vim 123loongson@LOonux:~$
Similar:
! The first word of the last command ----- the last command containing the word
Loongson @ loonux :~ $ LS-Al tar. Sh-RW-r -- 1 Root 628 16:44 tar. shloongson @ loonux :~ $! Lsls-Al tar. Sh-RW-r -- 1 Root 628 16:44 tar. shloongson @ loonux :~ $
Sudo !! ---- Run the previous command as root
Loongson @ loonux :~ $ Apt-Get install javae: Unable to open the lock file/var/lib/dpkg/lock-open (13: insufficient permissions) E: unable to lock the Status List Directory (/var/lib/dpkg/). Please check whether you are running as a root user? Loongson @ loonux :~ $ Sudo !! Sudo apt-Get install Java [Sudo] password for loongson:
# Cd------ switch between two non-recursive directories (premise: switch between two directories is completed in one step) loongson @ loonux :~ $ CD testdir/loongson @ loonux :~ /Testdir $ CD/home/loongson/CTCS2/loongson @ loonux :~ /CTCS2 $ CD-/home/loongson/testdirloongson @ loonux :~ /Testdir $ CD-/home/loongson/ctcs2loongson @ loonux :~ /CTCS2 $
Cd ~ Is to return to your home directory, Cd ~ User: Enter the Home Directory of a user
Date-d @ second -------- convert seconds to specific time
Loongson @ loonux :~ $ Date + % s1359009384loongson @ loonux :~ $ Date-d @ 14:36:24 Cst, Thursday, 13590093842013
man ascii
Show ASCII code table
netstat –tlnp
List the port numbers listened by the local Process
ssh user@server bash < /path/to/local/script.sh
Run a script on a remote machine. The biggest advantage of this command is that you do not need to copy the script to a remote machine.
yee@Loong:~$ cat sshtest.py #!/usr/bin/python# -*- coding: utf-8 -*-ls -al > re.txtyee@Loong:~$ ssh loongson@172.16.2.63 sh < sshtest.py The authenticity of host '172.16.2.63 (172.16.2.63)' can't be established.RSA key fingerprint is f2:78:cf:25:bc:68:43:4e:60:89:ca:2e:c9:0e:86:44.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '172.16.2.63' (RSA) to the list of known hosts.loongson@172.16.2.63's password: yee@Loong:~$
Remote machine: the script has been run and the output record file is as follows:
Loongson @ loonux :~ $ LS-lt total usage 2799804-rw-r -- r -- 1 loongson 5077 January 25 09:45 re.txt-RW-r -- 1 loongson 2 January 24 14:49 123
SSH user @ host CAT/path/to/remotefile | diff/path/to/localfile-
Compare a remote file with a local file
Loongson @ loonux :~ $ Cat re.txt total usage 2799932drwxr-xr-x 2 loongson 4096 download drwxr-XR-x 2 loongson 4096 15:24 music drwxr-XR-x 2 loongson 4096 15:52 January 17
Yee @ LOONG :~ $ Cat re.txt total 1153428drwxr-xr-x 2 yee 4096 2009-02-10 common drwxr-XR-x 2 yee 4096 2009-02-10 template drwxr-XR-x 4 yee 4096 2009-11-09 video drwxr-XR-x 2 yee yee 4096 2010-07-06 picture lrwxrwxrwx 1 yee 7 08-12 desktop-> export topyee @ LOONG: ~ $ SSH loongson@172.16.2.63 CAT/home/loongson/re.txt | diff re.txt-loongson@172.16.2.63's password: 1, 6c1, 4 <total 1153428 <drwxr-XR-x 2 yee 4096 Public <drwxr-XR-x 2 yee 4096 template <drwxr-XR-x 4 yee 4096 video <drwxr-XR-x 2 yee 4096 2010-07-06 figure <lrwxrwxrwx 1 yee 7 08-12 20:28 desktop-> desktop ---> total usage 2799932> drwxr-XR-x 2 loongson loongson 4096, December 11, January 17 15:24 Carrier> drwxr-XR-x 2 loongson 4096 December 18 15:52 music> drwxr-XR-x 2 loongson 4096 January 8 08:43 desktop Yee @ LOONG :~ $
View the latest modified files in a directory in real time
Watch-D-N 1 'df; LS-flat/Path'
When using this command, you need to replace the/path section. Watch is a real-time monitoring tool. The-D parameter will highlight the changed area, -N 1 indicates that the refresh interval is 1 second.
DF; LS-flat/path runs two commands. df is the output disk usage, and LS-flat lists all the files under/path.
Ls-flat parameters:
-F adds a file symbol to the end of the file to indicate the file type. There are */=> @ | these types. * indicates the executable file and/indicates the directory, = indicates the interface (sockets),> indicates the door, @ indicates the symbolic link, | indicates the pipeline.
-L display in list mode
-A display ..
-T sort files by Time
Displays the size of all subdirectories in the current directory.
Du-h -- Max-depth = 1
Loongson @ loonux :~ $ Du-h -- Max-depth = 1 4.0 K. /. gnome2_private8.0k. /. ssh48k. /. pulse4.0k. /video 4.0 K. /Public 101 m. /desktop 800 K. /. gstreamer-0.104.0K. /document 16 K. /. adobe
Net RPC shutdown-I ipaddressofwindowspc-u username % Password
Remotely shut down a Windows machine, but it may not be executed successfully, which is related to the settings above win;
Net parameters:
net timeto view or set time information net lookupto lookup host name or ip address net userto manage users net groupto manage groups net samto edit the local user database directly net lookupto look up various things net groupmapto manage group mappings net jointo join a domain net cacheto operate on cache tdb file net getlocalsid [NAME]to get the SID for local machine name net setlocalsid SIDto set the local machine SID net getdomainsid the machine SID and the domain SID on the local server net setdomainsid SIDto set the domain SID on member servers net changesecretpwto change the machine password in the local secrets database only this requires the -f flag as a safety barrier net statusShow server status net usersidlistto get a list of all users with their SIDs net usershareto add, delete and list locally user-modifiable shares net confto view and edit samba's registry based configuration net ads <command>to run ADS commands net rap <command>to run RAP (pre-RPC) commands net rpc <command>to run RPC commandsType "net help <option>" to get more information on that optionValid targets: choose one (none defaults to localhost)-S or --server=<server>server name-I or --ipaddress=<ipaddr>address of target server-w or --workgroup=<wg>target workgroup or domainValid miscellaneous options are:-p or --port=<port>connection port on target-W or --myworkgroup=<wg>client workgroup-d or --debuglevel=<level>debug level (0-10)-n or --myname=<name>client name-U or --user=<name>user name-s or --configfile=<path>pathname of smb.conf file-l or --longDisplay full information-V or --versionPrint samba version information-P or --machine-passAuthenticate as machine account-e or --encryptEncrypt SMB transport (UNIX extended servers only)
Convert input.png-gravity northwest-Background transparent-extent size output.png
Changing the size of a piece is a little troublesome because it has many relative parameters;
Lsof-I
View the activity status of the local network service in real time.
Root @ loonux:/home/loongson # lsof-I
Command PID user FD type device size/off node name
Avahi-dae 1433 avahi 12u IPv4 4020 0t0 udp *: mdns
Avahi-dae 1433 avahi 13u IPv6 4021 0t0 udp *: mdns
Avahi-dae 1433 avahi 14u IPv4 4022 0t0 udp *: 53714
Avahi-dae 1433 avahi 15u IPv6 4023 0t0 udp *: 44682
NTPD 1482 NTP 16u IPv4 3814 0t0 udp *: NTP
NTPD 1482 NTP 17u IPv6 3815 0t0 udp *: NTP
Vim SCP: // username @ host // path/to/somefile
Vim Remote File
Python-M simplehttpserver
To implement an HTTP service in one sentence and set the current directory as an HTTP service directory, you can access it through http: // ip: 8000. This may be the simplest HTTP server implementation on the planet.
However, if the command execution is interrupted, the service will be interrupted. It is very practical, and it is a good choice for downloading files with remote options;
Yee @ LOONG :~ $Python-M simplehttpserver
Serving HTTP on 0.0.0.0 port 8000...
172.16.7.94--[25/Jan/2013 11:35:33] "Get/HTTP/1.1" 200-
172.16.7.94-[25/Jan/2013 11:35:39] Code 404, message file not found
172.16.7.94-[25/Jan/2013 11:35:44] "Get/favicon. ico http/1.1" 404-
172.16.7.94--[25/Jan/2013 11:36:00] "Get/test. py HTTP/1.1" 200-
172.16.7.94--[25/Jan/2013 11:36:33] "Get/Shell/HTTP/1.1" 200-
If the index.html file exists in the folder, the index file is preferentially entered when an IP address is entered in the browser.
Python-M simplehttpserver 8000
wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
Download the entire www.example.com website.
yee@Loong:~$ wget --random-wait -r -p -e robots=off -U mozilla http://www.baidu.com
100% [============================================== ========>] 208,993 140 K/s in 1.5 s 10:58:36 (140 KB/s) -'www .baidu.com/cache/sethelp/img/green_browser1.jpg' is saved [208993/208993] -- 10:58:36 -- http://www.baidu.com/cache/sethelp/img/green_browser2.jpgis connected.
Www.baidu.com | 115.239.210.27 |: 80... connected. An HTTP request has been sent and is waiting for response... 200 OK length: 158563 (155 K) [image/JPEG] to be saved to 'www success>] 158,563 121 K/s in 1.3 scurl ifconfig.me
When your machine is on the Intranet, you can use this command to view the Internet IP Address
loongson@LOonux:~$ curl ifconfig.me222.92.8.142