Giving someone root access in linux is easy. Why would someone need to be root I don’t know but this is how you do it using the usermod command.
To add root access
[root@abika root]# id sys_admin
uid=508(sys_admin) gid=508(sys_admin) groups=508(sys_admin)
[root@abika root]# usermod -G root sys_admin
[root@abika root]# id sys_admin
uid=508(sys_admin) gid=508(sys_admin) groups=508(sys_admin),0(root)
To remove root access.
[root@abika root]# usermod -G sys_admin sys_admin
[root@abika root]# id sys_admin
uid=508(sys_admin) gid=508(sys_admin) groups=508(sys_admin)
2 easy ways find out what version of Ubuntu you’re running.
First option,
cat the /etc/issue file.
danny@family-desktop:/etc$ cat /etc/issue
Ubuntu 8.04.1 \n \l
Second option
cat the /etc/lsb-release file.
danny@family-desktop:/etc$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
or
run the lsb_release command with the “-a” switch.
danny@family-desktop:/etc$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Release: 8.04
Codename: hardy
Here’s an easy way to get the pid of a running process.
Running the “pidof” command will return the pid(s) for a running program. See sample below,
danny@pandora:~> pidof syslog-ng
2043
danny@pandora:~> pidof acpid
2045
danny@pandora:~> pidof /usr/bin/firefox
14408
danny@pandora:~> pidof /usr/bin/compiz
27164
danny@pandora:~> pidof /bin/bash
27011 17339 16792 16477 15151 14403
Simple right!?
Not many people I know use the tee command but I find it quite useful. I tend to use it quite often in my scripts actually.
So what does it do?
The tee command has the ability to take the standard input and redirected it to multiple outputs. For example, the ls command would normally just return file names on your screen but what if you also need to keep a log of those file names in a text file.
Using the tee command you could simply write something like this “ls * | tee -a output.txt“. The command will return the file names on screen and also append them to the output.txt file. Screenshot below,

A lightly more complex use of the command. I have a file with duplicate entries. Combining the tee command with the uniq and sort commands I am able print the desired output on screen and also dump it into the file output_sorted.txt. Screenshot below,

There are way more usages for the tee command but for today I stuck to the basic. I’ll try to post more about it in the future.
I develop quite a few bash scripts to automated backups and dropbox operation in my office. One of the usual requirements is to tar (tar.gz) the files locally and later untar them on the destination server when needed. I have a few simple scripts with interactive menus which help the data center operations team with their daily backup tasks.
One of the challenges during development was the ability to untar files on the backup server over SSH. The command by default will untar to the home directory instead of the target folder output always returned success but the files were nowhere to be found. This apparently is a limitation on the tar command, it did not know where to untar the files to when being executed over SSH. Fortunately the fix was really simple.
Original command,
ssh 127.0.0.1 'tar zxvf ~/test/files.tzr.gz'
The simple fix,
ssh 127.0.0.1 'cd ~/test/ ; tar zxvf files.tar.gz'
or, (thanks Aik)
ssh 127.0.0.1 'tar zxvf files.tar.gz -C ~/test/'
Here’s a video I put together to demonstrate the above. Hopefully I got it right.
Continue Reading ->