Install 7zip on Ubuntu:
sudo apt-get install p7zip-full

Check if 7zip is installed properly:
7z

To see a list of all files and folders in the current directory
ls -la

Create a compressed file named data.7z using the command
7z a data.7z data.txt

To create a compressed file with the contents of a directory, first cd into that directory (e.g. NameOfDirectory) and use the following command to generate a NameOfDirectory.7z file:
7z a -r NameOfDirectory

Extract a .7z compressed file:
7z e data.7z

___________________

 

Copy a directory/folder from local system to a remote system via SSH:
#CD into the directory on the local system
#-q tag is for making it silent so that you do not see the names of the files being copied on the terminal
scp -r -q SourceFolderName/ userNameOnRemoteSystem@XXX.XX.X.X:/home/user/destDirectory

 

Browse files on another ubuntu system from client ubuntu system:

This email address is being protected from spambots. You need JavaScript enabled to view it.

 

Find the size of a directory: du -sh dirname/

Tail like command for windows using Windows Powershell to extract last few lines of a large text file:

Get-Content "inputfile.txt" -Wait -Tail 3000 > tail.txt

 

Useful Linux Navigating Commands

Zip a folder (and exclude a sub-folder)

zip -r myarchive.zip dir1 -x dir1/ignoreDir1/**\* dir1/ignoreDir2/**\*

  • To remove a folder with all its contents (including all interior folders):

    rm -rf /path/to/directory
    
  • To remove all the contents of the folder (including all interior folders) but not the folder itself:

    rm -rf /path/to/directory/*
     

    or, if you want to make sure that hidden files/directories are also removed:

    rm -rf /path/to/directory/{*,.*}
    
  • To remove all the "files" from inside a folder(not removing interior folders):

    rm -f /path/to/directory/{*,.*}
    

Warning: if you have spaces in your path, make sure to always use quotes.

rm -rf /path/to the/directory/*

is equivalent to 2 separate rm -rf calls:

rm -rf /path/to
rm -rf the/directory/*

To avoid this issue, you can use 'single-quotes'(prevents all expansions, even of shell variables) or "double-quotes"(allows expansion of shell variables, but prevents other expansions):

rm -rf "/path/to the/directory/"*

Where:

  • rm - stands for remove
  • -f - stands for force which is helpful when you don't want to be asked/prompted if you want to remove an archive, for example.
  • -r - stands for recursive which means that you want to go recursively down every folder and remove everything.

To be updated more...