Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
home_server:home_server_setup:other_services:bash [2025-01-10 Fri wk02 11:03] – [BASH History Customisation and Use] baumkphome_server:home_server_setup:other_services:bash [2025-08-16 Sat wk33 19:41] (current) – [create] baumkp
Line 442: Line 442:
 ====create==== ====create====
 main ''tar'' create options, e.g.: ''tar -cvf archive_filename.tar file1 directory1 file2'' main ''tar'' create options, e.g.: ''tar -cvf archive_filename.tar file1 directory1 file2''
-  *''-c'' : for create archive, a pretty self-explanatory option if you want to create a new archive made from the files selected; +  *''-c'' : for create archive, a pretty self-explanatory option if you want to create a new archive made from the files selected.  The ''c'' option should be first.   
-  *''-v'' : for verbose, this is the reason why the command displays the files added to the archive when executing it; +  *''-v'' : for verbose, this is the reason why the command displays the files added to the archive when executing it. 
-  *''-f'' : for file, this option is used in order to specify the filename of the archive we want to create (in this case archive.tar)+  *''-f'' : for file, this option is used in order to specify the filename of the archive we want to create (in this case archive.tar), The ''f'' option should be just before the file name.
  
 +If backing up a root directory use the following as an example: ''sudo tar -czvPf filename /etc'' a better example is ''sudo tar -czvf filename -C / etc''
 +  *''-P'' : for Don't strip leading slashes from file names when creating archives.  This is not recommended as the absolute path will overwrite the information in the root directory, which will often and mostly lead to undesirable outcomes.  This is why the ''tar'' command will usually strip leading absolute path references to root directory, that is paths starting with ''/''.
 +  *''-C'' : for change to directory.  This changes the directory to ''/'' and then copies the files into the archive with relative paths, that is without the leading ''/''
 ====extract==== ====extract====
 ''tar -xvf archive_filename.tar'' ''tar -xvf archive_filename.tar''
Line 452: Line 455:
 ====list contents==== ====list contents====
 ''tar -tvf 'archive filename''' ''tar -tvf 'archive filename'''
 +  *''t'' will list the contents of the archive.
 +  *''v'' will list all the file parameters, without just the file path/name only.
 =====ps process===== =====ps process=====
 ''ps aux'' to see current process ''ps aux'' to see current process