Second week homework

Source: Internet
Author: User

1. What are the file management commands on Linux, their commonly used methods and their related examples?
CP: File copy
CP parameter original target file (clip) target file (clip)
Parameters
I: User interaction, general addition
V: With process
R: Recursive operation, copy folder

[[email protected] tmp]# cp-vi/etc/fstab/tmp//copy Fstab to tmp directory [[email protected] tmp]# CP-RVI/TMP/DIRA/TMP/TEST1/DIRB Copy the Dira directory to the Test1 directory

MV: File movement, renaming
Parameters
I: Tips, user interaction
F: Forced Override

[[email protected] tmp]# mv-i/tmp/fstab/tmp/test/fstab//move fstab to test directory [[email protected] tmp]# mv-i/tmp/dir1/tmp/t EST/DIR1//Move folder Dir1 to test directory [[email protected] tmp]# mv-i/tmp/fstab/tmp/fstab1//rename fstab to Fstab1

RM: File Delete
Parameters
-I: Delete prompt
-F: Force delete
-R: Recursive, delete folder

[[email protected] tmp]# rm-i/tmp/fstab//delete fstab file [[email protected] tmp]# rm-fi/tmp/test1//delete test1 directory

2. Bash's work characteristics the command execution status return value and command line expansion are involved in the content and its sample demonstration.
The command-line deployment is:
~

CD ~//Switch Home directory

{}:

Mkdir-p X/{a,b}//In the creation of A and B subdirectories, respectively, in the X directory

There are two types of execution status return values:
True: denoted by 0

[Email protected] tmp]# echo $?0

False: represented by 1-255 for different error return information

[[email protected] tmp]# Cat/etc/fstabaaacat:/etc/fstabaaa:no such file or Directory[[email protected] tmp]# echo $?1

3. Use the command line expansion function to complete the following exercises:
(1), create/tmp directory: A_c, A_d, B_c, B_d

[[email protected] tmp]# MKDIR-PV {a,b}/{c,d}

(2), create the/tmp/mylinux directory:
mylinux/
├──bin
├──boot
│└──grub
├──dev
├──etc
│├──rc.d
││└──init.d
│└──sysconfig
│└──network-scripts
├──lib
│└──modules
├──lib64
├──proc
├──sbin
├──sys
├──tmp
├──usr
│└──local
│├──bin
│└──sbin
└──var
├──lock
├──log
└──run

[Email protected] tmp]# MKDIR-PV mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig,network-scripts},lib/ Modules,lib64,proc,sbin,sys,tmp,usr/{local,bin,sbin},var,lock,log,run}

4, what is the metadata information of the file, what does it mean, how to view it? How to modify timestamp information for a file.
Metadata contains file permissions, size, owning, group, and modification time information

[Email protected] tmp]# ls-l fstab-rw-r--r--. 1 root root 787 00:13 fstab

     timestamp modified with the touch command

[[email protected] tmp]# touch -a -t 201608081022 fstab[[email  PROTECTED] TMP]# TOUCH -M -T 201608091022 FSTAB[[EMAIL PROTECTED] TMP] # stat fstab  file:  ' Fstab '   Size: 787              Blocks: 8           IO Block: 4096   regular fileDevice: fd00h/64768d     Inode: 794200      Links: 1Access:  (0644/-rw-r--r--)   Uid:  (    0/    root)    Gid:  (     0/    root) access: 2016-08-08 10:22:00.000000000 + 0800modify: 2016-08-09 10:22:00.000000000 +0800change: 2016-08-14 10:42:39.743667599  +0800

5, how to define the alias of a command, how to reference the execution result of another command in the command?
Use alias to define an individual name, alias aliasname = Command + option
To use a pipe to reference another command to execute the result

[Email protected] tmp]# CAT/ETC/PASSWD | Grep-e ' ^root\> '--color=auto

6. Display all files or directories in the/var directory that start with L, end with a lowercase letter, and have at least one digit (can have other characters) appear in the middle.

[[email protected] tmp]# ls/var/l*[[:d igit:]]*[[:lower:]]

7. Displays files or directories that start with any number in the/etc directory and end with a non-numeric number.

[Email protected] tmp]# ls/etc/[[:d igit:]]*[^0-9]

8, Show/etc directory, start with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.

[Email protected] tmp]# ls/etc/[^[:alpha:]][[:alpha:]]*

9. In the/tmp directory, create a file that starts with Tfile, followed by the current date and time, with a filename such as: tfile-2016-08-06-09-32-22.

[Email protected] tmp]# dirname=$ (date +tfile-%y-%m-%d-%h-%m-%s) [[email protected] tmp]# touch/tmp/$dirname

Or

[[email protected] tmp]# Touch tfile-' Date +%y-%m-%d-%h-%m-%s '

10. Copy all the files or directories in the/etc directory to the/tmp/mytest1 directory that begin with P and do not end with a number.

[[email protected] tmp]# mkdir/tmp/mytest1[[email protected] tmp]# cp-irv/etc/p*[^[:d igit:]]/tmp/mytest1/

11. Copy all files or directories ending with. D in the/etc directory into the/tmp/mytest2 directory.

[Email protected] tmp]# mkdir/tmp/mytest2[[email protected] tmp]# Cp-irv/etc/*.d/tmp/mytest2

12. Copy all files in the/etc/directory that begin with L or M or N and end with. conf to the/TMP/MYTEST3 directory.

[Email protected] tmp]# mkdir/tmp/mytest3[[email protected] tmp]# cp-iv/etc/[lmn]*.conf/tmp/mytest3/

Second week homework

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.