Posted by guptaradhesh on January 7, 2014
Doing an scp gave the following error message:
Permission denied (publickey)
The reason for the above is that it asks for ec2 instance password while we use .ppk file now days.
Here are the quick steps one should follow:
- server 1
- generate the id_rsa.pub
ssh-keygen -t rsa
- No need to enter any passphrase
- server 2
- Open /etc/ssh/
- If logged as ec2-user; susu su
Uncomment the lines below if they are not already
- append contents of id_rsa.pub file of server 1 to authorized_keys of server 2
Posted in tech, unix | Tagged: ec2, id_rsa.pub, scp | Leave a Comment »
Posted by guptaradhesh on July 27, 2012
One would frequently notice this training redirect construct in many Unix commands – all it means is, ALL output from this command should be pushed into /dev/null.
> /dev/null 2>&1
/dev/null is a place where we can dump anything we don’t want to use. Since, 1 is stdout and 2 is stderr: 2>&1 can be interpreted as redirect stderr to stdout. Thus, Error messages which go to stderr are redirected to stdout which is being redirected to dev/null. Therefore, no output at all.
Posted in tech, unix | Tagged: /dev/null, 2>&1, bash, stderr, stdout, unix | Leave a Comment »
Posted by guptaradhesh on June 20, 2012
It counts the number of substitutions without actually performing the substitutions.
Posted in tech, unix | Tagged: string count, unix, vi, vim | Leave a Comment »
Posted by guptaradhesh on November 8, 2010
a simple sed command to do the same is as:
sed -e 's/^ *//' data
Posted in tech, unix | Tagged: sed, shell, unix | 1 Comment »
Posted by guptaradhesh on November 1, 2010
ctime: is the inode change time. When does the inode change, when you of course update a file, but also when you do things like changing the permissions of the file but not necessarily its contents. We can view the ctime with the ls -lc command.
atime: stands for access time which is when the file was last read. Displaying the contents of a file or executing a shell script will update a file’s atime. We can view the atime with the ls -lu command.
mtime: is the modification time, so if you change the contents of the file, this time is updated. Keep in mind when you change the contents of a file and and save it, the inode gets updated as well for that file, so ctime always changes too. We can view this with ls -l.
Therefore, when mtime changes, ctime will always change.
Posted in tech, unix | Tagged: atime, ctime, mtime, shell, unix | Leave a Comment »
Posted by guptaradhesh on October 25, 2010
>> finding if a directory exists or not:
to check if a directory ‘tempDir’ exists in your home directory, the shell command would be,
$ [ ! -d ~/tempDir ] && echo 'Directory tempDir not found'
$ [ -d ~/tempDir ] && echo 'Directory found' || echo 'Directory tempDir not found'
Similarly, to check if a file exists, we use -f parameter in the above command.
Parameters like -r, -w, -x are also available to check if the file exists and is readable, writable or executable resp.
>> Adding a directory to the path of user or all users:
"export PATH" must be added to ensure that any programs called
by bash have the altered $PATH variable.
- To add a directory to the path of a single user,
place the lines in that user's .bash_profile file.
- For all users globally, set a path in /etc/profile.
Posted in tech, unix | Tagged: unix | 1 Comment »