简体   繁体   中英

How to create an archive and chmod it

I should create a file inside this file an archive. When I create it, I should use chmod so that the archive should have 757 rights.

I did this but I failed, is this right or wrong? :

$ mkdir file1
$ cd file1
# here i should create an archive but how i dont know
$ chmod 757 archivename

Use touch command first:

bash-4.3$ mkdir a                                                                                                                                                                                                            
bash-4.3$ cd a                                                                                                                                                                                                               
bash-4.3$ pwd                                                                                                                                                                                                                
/home/cg/root/a                                                                                                                                                                                                              
bash-4.3$ touch a.txt                                                                                                                                                                                                        
bash-4.3$ chmod 757 a.txt                                                                                                                                                                                                    
bash-4.3$ ls -lrt                                                                                                                                                                                                            
total 0                                                                                                                                                                                                                      
-rwxr-xrwx 1 18207 18207 0 May  4 11:29 a.txt

I think this is what you need:

$ mkdir file1
$ cd file1
$ touch actual_file.txt
$ cd ..
$ tar czvf file1-archive.tar.gz file1/
$ chmod 757 file1-archive.tar.gz

This creates an archive of everything inside the file1 folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM