Linux Cookbook 3

Files And Dirs

1. touch ---create a new, empty file
            vi filename is also ok
2. mkdir ---make directory
            mkdir -p ---to make all directories in the path
3. space in filename
            use '' or "" or /
            ls 'top secret'
            ls "top secret"
            ls top/ secret
4. cd ---change the current working dir
            1)cd ---To make your home directory the current working directory                       
            2)cd - ---Changing to the Last Directory You Visited
            3)pwd ---Getting the Name of the Current Directory
5. ls ---Listing Directories
            ls --color ---Listing Directories in Color
                    Some of the default color settings include displaying directory names in blue,
                    text files in white, executable files in green, and links in turquoise.
                    Many systems are set up to use this flag by default, so that using ls
                    with no options will list in color. If yours isn’t set up this way, and you’d like
                    it to be, you can always make ls a shell alias word for ls --color in your
                    .bashrc startup file
             ls -F ---Listing File Types
                    regular files are displayed as usual
                    / File is a directory.
                    * File is executable.
                    @ File is a symbolic link
                    | File is a fifo
                    = File is a socket
             ls -l(long) ---Listing File Attributes
                    The first character in this column specifies the file type;
                    the hyphen (-) is the default and means that the file is a regular file.
                    Directories are denoted by d
                    symbolic links are denoted by l
             ls --full-time ---show the full time and date
             ls -h ---human readable
             ls -a ---To list all files in the current directory, include Hidden Files
                    . ---a period character (.) means hidden file
             ls -A --- ls-a - . - ..
             ls -1 ---to list a directory in a single column
             ls -x ---To list the contents in columns printed horizontally
             ls -m ---to output files not in columns at all, but in a single horizontal line, separated by commas.
             ls -S ---To sort files by size, default is sorted alphabetically
             ls -t ---by time
             ls -X ---by extension
             ls -v ---so that file-2 will come between file-1 and file-10, very useful
             ls -r ---to reverse the order of the sorted output, can work with all the other sort options
             ls -U ---to turn off all sorting and output files in unsorted order—the order they appear on the disk.
             ks -R ---lists the contents of a directory recursively
6. cp ---Copying Files and Directories            
             cp -v ---to list files as they are copied
             cp -p ---to preserve all of the attributes of the original, whenever possible,
                      including its timestamp, owner, group, and permissions.
                      in every respect except for its name
             cp -a --- same as cp -p but recursively
             basename ---for i in ~/photographs/*; { cp -a $i/src /mnt`basename $i`; }
7. mv ---to move, or rename, a file or directory to a different location.
             Renaming a file is the same as moving it
             $ mv notes notes.old ---To rename the file notes to notes.old
8. rename ---
9. rm ---to delete a file and remove it from the system
             Removing a File with a Strange Name
                       1) use tab
                       2) use pattern, e.g rm -i ?cat
                       3) rm -- -cat ---To remove the file -cat from the current directory            
             Removing Files without Verification
                       $ yes | rm -R scrap
10. ln ---Linking a File to Another
             ln -s symbolic link
11. tree ---Listing Directory Tree Graphs
             tree -d ---only show dir                           


                   

permission

1. cat /etc/group ---To list the available groups on the system
2. groups ---Listing the Groups a User Belongs To
             groups marlow ---To list the group memberships of user marlow
3. members groupname ---to list the members of a particular group
             $ grep ^crew: /etc/group | cut -d : -f 4
4. $ chgrp bridge cruise ---To change the group ownership of file cruise to bridge
             -R ---recursively
5. ls -l         
             -rwxrw-r-- 1 captain crew 8,420 Jan 12 21:42 cruise
             The first character (“-”) is the file type; the next three characters (“rwx”)
             specify permissions for the user who owns the file; and the next three (“rw-”)
             specify permissions for all members of the group that owns the file except for
             the user who owns it. The last three characters in the column (“r--”) specify
             permissions for all other users on the system.            
6. chmod ---Changing the Permissions of a File
             u ---user
             g ---group
             o ---other users
             a ---all users
            
             + ---add
             - ---remove
             = ---Make these the only permissions the user has for this file

             r ---read
             w ---write
             x ---execute
             e.g
             chmod a+rw cruise ---Making a File Public
             chmod a+x myscript ---Making a File Executable
             chmod go= cruise ---To make the file cruise private from all users but yourself
             chmod go-w cruise ---Write-Protecting a File

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值