Posts

Showing posts with the label SHELL

What does '>/dev/null 2>&1' mean in SHELL?

'>' is for redirection '/dev/null' is a black hole where any data sent, will be discarded '2' is the file descriptor for Standard Error '&' is the symbol for file descriptor (without it, the following 1 would be considered a filename) '1' is the file descriptor for Standard Out $ cat foo.txt foo bar baz redirection is the mechanism used to send the output of a command to another place. Here, for example, we are redirecting it to a file called out.txt: $ cat foo.txt > out.txt we could rewrite the command like this: $ cat foo.txt 1> out.txt we don’t see any output in the screen. We changed the standard output (stdout) location to a file. $ cat out.txt foo bar baz if we try to cat a file that doesn’t exist, like this: $ cat nop.txt > out.txt cat: nop.txt: No such file or directory we see the error output in the screen, because we are redirecting just the standard output, not the standard error. Using std...

[FreeBSD] How to change from sh to bash as default shell

1. Installing bash $ sudo pkg install bash Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: bash: 4.4.12_3 Number of packages to be installed: 1 The process will require 8 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: $ sudo pkg install bash Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: bash: 4.4.12_3 Number of packages to be installed: 1 The process will require 8 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: y [1/1] Fetching bash-4.4.12_3.txz: 100% 1 MiB 1.5MB/s 00:01 Checking integrity... done (0 conflicting) [1/1] Installing bash-4.4.12_3... Extracting bash-4.4.12_3: 100% 2. List of acceptable shel...

LINUX - How to Compress a Whole Directory

1.Use the tar command. tar -zcvf archive-name.tar.gz directory-name -z : Compress archive using gzip program -c: Create archive -v: Verbose i.e display progress while creating archive -f: Archive File name For example, say you have a directory called /home/admin/workspace and you would like to compress this directory then you can type tar command as follows: $ tar -zcvf src.tar.gz /home/admin/workspace If you wish to restore your archive then you need to use the following command $ tar -zcvf src.tar.gz /home/admin/workspace -x: Extract files Advanced. tar -jcvf src.tar.bz2 /home/admin/workspace # even more compression #change the -c to -x to above to extract 2.Use the zip command. $ zip -r file-name.zip /path/to/directory $ unzip file-name.zip