1. CD
CD ~ Username: commands are used to switch directories or to switch the user's home directory.
[Email protected] ~]# CD ~123
[Email protected] 123]# pwd #查看当前路径
/home/123
A user's home directory is a folder created for a specific user who has ownership of the contents of the folder, but not all of the programs in the user's home directory are owned by that user. The owner of the following test2 file is root because it is a file created under root privileges and creates a read-only permission test2 on the desktop.
[email protected] desktop]# Touch test2
[Email protected] desktop]# ls-l
Total 2220
-rw-r--r--. 1 root root 2272130 6 cacti-0.8.8b.tar.gz
-rw-rw-r--. 1 123 123 0 Nov 1 03:38 new file
-rw-rw-r--1 123 123 0 Nov 22:42 new file (copy)
-rw-r--r--1 root root 0 Nov 23:16 test2
If you log on to 123 users by Su, when you create a test4 file, its owner belongs to 123 users and has read and write permissions.
[[email protected] desktop]$ SU 123
Password:
[[email protected] desktop]$ ls
cacti-0.8.8b.tar.gz New File New file (copy) Test2 Test3
[email protected] desktop]$ Touch test4
[Email protected] desktop]$ ls-l
Total 2220
-rw-r--r--. 1 root root 2272130 6 cacti-0.8.8b.tar.gz
-rw-rw-r--. 1 123 123 0 Nov 1 03:38 new file
-rw-rw-r--1 123 123 0 Nov 22:42 new file (copy)
-rw-r--r--1 root root 0 Nov 23:16 test2
-rw-rw-r--1 123 123 0 Nov 23:18 test3
-rw-rw-r--1 123 123 0 Nov 23:20 test4
2. Type
The type of the command that can be realistic through the type. Commands in Linux are divided into internal commands and external commands.
[[Email protected] desktop]$ type cut
Cut Is/usr/bin/cut #外部命令 (in a corresponding directory)
[[Email protected] desktop]$ type echo
Echo is a shell builtin #内部命令
3, Printenv
This command allows you to view the environment variable information for the system, which is the same as the Java setting, and a whole bunch of information only knows that path is the information of the environment variable. The newly developed program also needs to be set in the environment variable.
[Email protected] desktop]# printenv
Orbit_socketdir=/tmp/orbit-123
Hostname=localhost.localdomain
Term=xterm
Shell=/bin/bash
xdg_session_cookie=2604b541bf302be0cd47ddec00000011-1479446380.885020-236895646
histsize=1000
Gtk_rc_files=/etc/gtk/gtkrc:/home/123/.gtkrc-1.2-gnome2
windowid=46138793
User=123
ls_colors=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05 ; 37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*. taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*. Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31 :*. deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*. jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*. xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*. mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*. qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv =01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*. xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:* . au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*. WAV=01;36:*.AXA=01;36:*.OGA=01;36:*.SPX=01;36:*.XSPF=01;36:
Gnome_keyring_socket=/tmp/keyring-ejyje6/socket
Ssh_auth_sock=/tmp/keyring-ejyje6/socket.ssh
session_manager=local/unix:@/tmp/. ice-unix/2354,unix/unix:/tmp/. ice-unix/2354
Username=123
Desktop_session=gnome
Mail=/var/spool/mail/123
Path=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/123/bin
Pwd=/home/123/desktop
Gdm_keyboard_layout=us
Lang=en_us. UTF-8
gnome_keyring_pid=2344
Gdm_lang=en_us. UTF-8
Gdmsession=gnome
Ssh_askpass=/usr/libexec/openssh/gnome-ssh-askpass
Histcontrol=ignoredups
Home=/root
shlvl=11
gnome_desktop_session_id=this-is-deprecated
Logname=123
dbus_session_bus_address=unix:abstract=/tmp/dbus-mmui3c39vl,guid=b6fecbcb44a8fd92e501ec9b0000003d
Lessopen=|/usr/bin/lesspipe.sh%s
Windowpath=1
display=:0.0
G_broken_filenames=1
Colorterm=gnome-terminal
_=/usr/bin/printenv
4, Hash
The hash command is used to display the number of times the command is tapped on the screen. The hash-r is used to clear the cache information for this command. When the command used in the hash is used again, it will not be called in the kernel, but will be removed directly from the cached KV (key value) database, which is very fast.
[[email protected] desktop]# hash
Hitscommand
1/bin/grep
1/bin/vi
1/usr/bin/man
2/usr/bin/printenv
1/usr/bin/clear
5. Date
Display the system time, the system time here is the kernel time of the system, the core time is the analog time oscillator timing, the system after the installation will read the host hardware time, and then will be self-timer. Use Date-u to set the time of the system by the hour of the month.
[Email protected] desktop]# date-u 1118160216.30
Fri 16:02:30 UTC 2016
Some wildcard options are also included in the Date command, in 2016/11/18, for example,%y=16,%m=11,%d=18, when using a wildcard field, add + after date.
[[Email protected] desktop]# Date
Fri Nov 16:11:13 PST 2016
[Email protected] desktop]# date +%y
16
[Email protected] desktop]# date +%m
11
[Email protected] desktop]# date +%d
18
This is the result of changing the letter from the letters above the wildcard characters to uppercase.
[Email protected] desktop]# date +%y
2016
[Email protected] desktop]# date +%m
13
[Email protected] desktop]# date +%d
11/18/16
Date can also output text
[[Email protected] desktop]# Date + "Today is%d"
Today is 18
[[Email protected] desktop]# Date + "This year is%Y"
This is 2016
6, Clock,hwclock
It's been said in addition to date that you can view the current time, and one is that hardware time is viewed by clock, and clock and date may not be the same.
[[Email protected] desktop]# Date
Fri Nov 16:22:02 PST 2016
[Email protected] desktop]# clock
Fri 12:22:45 AM PST-0.906975 seconds
The above system time and hardware time is different, the system time is correct, can be modified by hwclock-w.
[Email protected] desktop]# hwclock-w
[Email protected] desktop]# clock
Fri 04:24:43 PM PST-0.141483 seconds
[[Email protected] desktop]# Date
Fri Nov 16:24:51 PST 2016
There is also a command cal can view the calendar for the current year, and cal-y can view the specified year.
[[email protected] desktop]# cal
November 2016
Su Mo Tu We Th Fr Sa
1 2 3) 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Linux common commands (cd,type,printenv,hash,date, clock, Hwclock)