-
Create a new directory: mkdir
Format is mkdir [directory name]
MkDir can build multi-level catalogs
[Email protected] ~]$ mkdir C
[Email protected] c]$ mkdir-p C1/C2/C3
-
Create a new document: Touch
[[email protected] c]$ Touch pri
[[email protected] c]$ ls
C1 pri
-
To set access permissions for a file chmod
Format: User symbol + (-) permissions file name
U: Owner g: Group O: Other
give u plus permissions:
[[email Protected] c]$ chmod u+r+w pri
-rw-rw-r--. 1 caibei caibei 0 may 04:55 pri
Give u minus permissions:
[[Emai L protected] c]$ chmod u-r pri
[[email protected] c]$ ll
Total 4
--w-rw-r--. 1 Caibei Caibei 0 may 04:55 pri
can also use octal for permissions, 0 for no, 1 for this permission
For U,g,o plus all permissions:
[[email Protected] c]$ chmod 777 pri
[[email protected] c]$ ll
Total 4
-rwxrwxrwx. 1 Caibei Caibei &NB Sp 0 04:55 pri
-
Change file owner Chown
Note: Only root has permission to use
Change the PRI file to Caibei owning:
[Email protected] c]$ chown root pri
chown:changing ownership of ' pri ': Operation not permitted
[email protected] c]$ su
Password:
[[email protected] c]# chown Caibei pri
[email protected] c]# LL
Total 4
Drwxrwxr-x. 3 Caibei caibei 4096 may 04:44 C1
-rwxrwxrwx. 1 Caibei caibei 0 may 04:55 pri
-
Change the owning group of the file Chgrp
[[email protected] c]# chgrp caibei pri
[email protected] c]# LL
Total 4
Drwxrwxr-x. 3 Caibei caibei 4096 may 04:44 C1
-rwxrwxrwx. 1 Caibei caibei 0 may 04:55 pri
-
View or modify the mask umask
New Folder Default permissions: 0666-Mask
New directory default permissions: 0777-Mask
[Email protected] c]# umask 0422
[email protected] c]# LL
Total 4
Drwxrwxr-x. 3 Caibei caibei 4096 may 04:44 C1
-rwxrwxrwx. 1 Caibei caibei 0 may 04:55 pri
-rw-r--r--. 1 caibei Root 0 May 05:32 Pro
[Email protected] c]# umask
0422
-
Display of files and directories ls
Ls-a Show all filenames include file names that are hidden by.
Ls-i list File Inode numbers
Ls-f appended with a character description file type after each file name, ' * ' executable plain file, '/' directory, ' @ ' link
[Email protected] c]# ls-a
. .. C1 PRI Pro
[Email protected] c]# ls-i
787323 C1 787332 pri 787304 Pro
[Email protected] c]# ls-f
c1/pri* Pro
-
Transform Catalog CD
format; CD file name
CD: Return to Parent directory
CD ~ Return to your home
CD-Return to the directory you just
[[Email protected] c]# CD
[Email protected] ~]# CD.
BASH:CD.: Command not Found
[Email protected] ~]# CD ~
-
Time Date
Format: Date +%y_%m_%d_%h:%m:%s
[[Email protected] ~]# Date
Sat May 05:59:19 PDT 2016
[Email protected] ~]# date +%y_%m_%d_%h:%m:%s
2016_05_14_06:00:19
-
Timestamp: Total number of seconds from start to current
[Email protected] ~]# date +%s
1463231013
[Email protected] ~]# date +%y:%m:%d-d @1463231013
2016:05:14
-
Delete Empty directory RmDir
-P even delete the upper directory
[Email protected] ~]# mkdir p
[Email protected] ~]# RmDir p
-
Delete File rm
Rm-r Delete directory and all of the following files
Rm-i will ask when you delete
Rm-f Force Delete
[Email protected] ~]# rm-i C
Rm:remove Regular empty file ' C '?
-
Copy files or directories CP
Format CP Source Files Directory
CP Source File Source file
[[email protected] ~]# CP C C1
[[email protected] ~]# Touch b
[[email protected] ~]# CP c b
Cp:overwrite ' B '?
-
Returns the file name and directory name DirName basename
Format: basename file name
[Email protected] ~]# basename C
C
[Email protected] ~]# dirname C
.
-
Move files or directories or rename MV
Mv-f Force move
Mv-i will ask whether to move
[Email protected] ~]# MV C C2
16. show file Contents more
[Email protected] ~]# count=0; While [$count-lt];d o echo "$count" >>file;
> Let count++; Done
17. View Files Less
Format: Less file name
[[email protected] ~]# less file
18. Calendar Cal
[[email protected] ~]# cal
May 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 31
19. View the first few lines of the file head
[[email protected] ~]# head file
0
1
2
3
4
5
6
7
8
9
20. View File type
[[Email protected] ~]# file file
File:ascii text
21. View file location which
Whereis:
[[email protected] ~]# which file
/usr/bin/file
[[email protected] ~]# Whereis file
File:/usr/bin/file/usr/share/file/usr/share/man/man1/file.1.gz/usr/share/man/man1p/file.1p.gz
22.find looking for a specific file path
Find. -name file name
. Represents the current directory/representation root directory
Find/-mtime N modify search files by N days ago
Find/-atime n finds files by accessing file time
Find/-ctime n Search by file creation time
[[email protected] ~]# find. -name file
./file
[[email protected] ~]# Find/-name file
/root/file
/usr/share/file
/usr/bin/file
/usr/src/kernels/2.6.32-431.el6.i686/include/config/pnfs/file
/usr/src/kernels/2.6.32-431.el6.i686/include/config/security/file
/usr/src/kernels/2.6.32-431.el6.i686/include/config/file
/selinux/class/file
/selinux/initial_contexts/file
/file
Find-print: output of matching files
[Email protected] ~]$ Find-print
.
./C
./C/3
./c/.file
./C/2
./C/1
./c/b
./c/pei
./c/pri
./test
Find-user Username: Press Username to find
[Email protected] ~]$ Find-user Caibei
.
./C
./test
./.pulse
Find-nouser: Press no username to find
[Email protected] ~]$ Find-nouser Caibei
Find:paths must precede Expression:caibei
Usage:find [-h] [-l] [-P] [-olevel] [-D help|tree|search|stat|rates|opt|exec] [path ...] [Expression]
Find-newer F1!F2 find newer than F1 F2 old files
[Email protected] ~]$ find-newer test.c!c
Find-newer test.c chown Root pri
Find:paths must precede Expression:chown
Usage:find [-h] [-l] [-P] [-olevel] [-D help|tree|search|stat|rates|opt|exec] [path ...] [Expression]
Find-type b Search by type of file
[Email protected] ~]$ Find-type D
.
./C
./c/pei
./.pulse
./videos
./.gnote
./.gnote/addins
./.gnome2
./.gnome2/keyrings
./.gnome2/gedit
./.gnome2/panel2.d
./.gnome2/panel2.d/default
./.gnome2/panel2.d/default/launchers
./.gnome2/nautilus-scripts
./.dbus
./.dbus/session-bus
./templates
./music
./.config
./.config/gtk-2.0
./.config/gnome-session
./.config/gnome-session/saved-session
./.config/gnome-disk-utility
./.config/gnome-disk-utility/ata-smart-ignore
./.gstreamer-0.10
./.mozilla
./.mozilla/plugins
./.mozilla/extensions
./pictures
./documents
./.local
./.local/share
./.local/share/applications
./.local/share/gvfs-metadata
./.local/share/trash
./.local/share/trash/expunged
./.local/share/trash/info
./.local/share/trash/files
./.gconf
./.gconf/desktop
./.gconf/desktop/gnome
./.gconf/desktop/gnome/accessibility
Find-size n Find files are n blocks of files
[Email protected] ~]$ Find-size 2
./.pulse/f844858f676102d9b6631da400000039-card-database.tdb
./.xsession-errors
./.config/user-dirs.dirs
./.local/share/gvfs-metadata/home
./.viminfo
./.gconf/apps/gnome-terminal/profiles/default/%gconf.xml
./.gconf/apps/panel/applets/window_list/prefs/%gconf.xml
./.bash_history
Find _depth make files look up this directory before finding subdirectories
[Email protected] ~]$ find-depth
./C/3
./c/.file
./C/2
./C/1
./c/b
./c/pei
./c/pri
./C
./test
Find-follow encounters a symbolic link file, it tracks the file that the link refers to
[Email protected] ~]$ Find-follow
.
./C
./C/3
./c/.file
./C/2
./C/1
./c/b
./c/pei
./c/pri
./test
Find-mount do not cross file system mount points when searching for files
[Email protected] ~]$ Find-mount
.
./C
./C/3
./c/.file
./C/2
./C/1
./c/b
./c/pei
./c/pri
./test
Linux basic commands