I need to convert different timezone to my local time and date?Using date command you can convert to different date and time zones to your local time zone defined by:
$ ls -l /etc/localtime lrwxrwxrwx. 1 root root 38 Jun 11 13:08 /etc/localtime -> ../usr/share/zoneinfo/Australia/SydneyIn the below example we will convert UTC time to EST:
$ date -d '2014-06-26 23:00 UTC' Fri Jun 27 09:00:00 EST 2014Read more...
How can I remove duplicate lines from my text file?The easiest way to remove duplicate files from a text file as by use sort and uniq commands. Consider a following text file:
$ cat file.txt How can I remove duplicate lines from my text file? use sort and uniq commands use sort and uniq commands How can I remove duplicate lines from my text file?Read more...
How can I retrieve yesterday date using bash?
$ date '+%A, %Y-%m-%d' Saturday, 2014-06-28 $ date -d "yesterday" '+%A, %Y-%m-%d' Friday, 2014-06-27Read more...
#!/bin/bash MAX=3 for ((i=1; i <= MAX ; i++)) ; do echo "$i" doneRead more...
-xbash option during script execution. This will print all lines of code that is execute. For an illustration let's consider a following example:
#!/bin/bash echo hello myvar=3 echo $myvarTo debug this bash shell script use
-xbash option during script execution:
$ bash -x bash-script.sh + echo hello hello + myvar=3 + echo 3 3Read more...
echo Hellodisregarding the "$" sign at the beginning of the line which only simply indicates that you supposed to type command as a non-privileged user:
$ echo Hello HelloIn the above example you have type command
echowhich simply prints anything passed to it. In this case we passed string "Hello" and thus our string we printed on the second line.
whichcommand to reveal a location of BASH interpreter on your system:
$ which bash /usr/bin/bashNow we are ready to write our first BASH shell script. Open your favorite text editor and enter the following code:
#!/usr/bin/bash echo "Shell Scripting"Note that first line contains our interpreter which is indicated by the fact that is is located on the first line of our script as well as that it is prefixed with
#!symbols. On the second line we have typed our already know command
echofollowed by string to be printed out. Save this file in your home directory using name
inithave its our parent identified by PPID. When you start process using your current shell the shell itself becomes a parent for your newly started process. The trouble with this approach is that this may not be always desirable since when parent process is terminated its child dies with it. The happens very often when login into server using ssh, telnet etc. After log out parent shell is terminated and thus terminating all processes forked from it. Let's explore some way how to avoid this necessary but sometime undesired system behavior:
$ nohup myjobs.sh & nohup: ignoring input and appending output to ‘nohup.out’Entire output if any is appended to nohup.out file for later review
yescommand imitatively and at the same time detaching this process form a current working shell.
$ at now at> yes > /dev/null at>Read more...
job 2 at Thu Jun 26 11:12:00 2014
/etc/shadow. In the below example we include "X" character thus making user's password impossible to decrypt something meaningful:
lubos:X$6$1ANrXcst$H4yOxEjNSNJAYdwe6q6ygHW3yGC/GhRW0:16243:0:99999:7:::It needs to be mentioned that this method only works if all users and services are authenticating against /etc/passwd file. You system may have custom configured PAM modules so make sure that nothing gets through.
usermodcommand in order to disable user account. However, using this method is simply just a shortcut to the above procedure since all what usermode does is to place "!" character in front of encrypted user password located in
/etc/shadowfile. In the following example we are going to disable user account "lubos" using
# usermode -L lubosNo output will be produced and result can be seen by examining /etc/password file.
lubos:!$6$1ANrXcst$H4yOxEjNSNJAYdwe6q6ygHW3yGC/GhRW0:16243:0:99999:7:::To enable user account you can either remove "!" sign from the /etc/password file or use
# usermode -U lubosRead more...
yescommand by redirecting it standard output to
$ yes > /dev/nullAfter execution of the above command your shell command line becomes unresponsive since it is entirely dedicated to you "yes" process. From here you have two options. Either terminate this process by CTRL+C key combination or or stop the process using CTRL+Z. Let's stop the process:
$ yes > /dev/null ^Z + Stopped yes > /dev/nullRead more...
# apt-get install gawk lm-sensors binutils mesa-utils hddtemp sudo
# cd /tmp/ # wget -Nc --no-check-certificate https://inxi.googlecode.com/svn/trunk/inxi.tar.gz # tar xzf inxi.tar.gz
# cp /tmp/inxi /usr/local/bin/
# cp /tmp/inxi.1.gz /usr/share/man/man1/Read more...