-
vi editor useful commands
Description Command comment all the lines :%s/^/# uncommnet all the lines :%s/^#/ comment line no. m to n :m,ns/^/# uncomment line no. m to n :m,ns/^#/ add comma after all the lines :%s/$/, remove comma after all the lines :%s/,$/ remove comma after line no. m to n :m,ns/,$/ search for a string from forward /string search for a string from backward ?
-
Everyday Linux hacks and tips
Here are some useful linux commands, i frequently use
1. Removing grep result from ps output ps aux | grep [d]hcp By putting brackets, we are searching for a regex and preventing grep from matching itself. Since [d]hcp doesn’t match the [d]hcp regular expression, so grep won’t show up in the results.
To understand more, play with ps, grep and regex.
Below is the ouput of above command with and without brackets.
-
Resolving SSH Authentication issues
How to resolve SSH Authentication issues 1. Problem: I wanted to access an Ubuntu node from a CentOS node without any password. To accomplish this, i needed to setup SSH keys. So I followed the following steps:
a. Generated SSH keys using ssh-keyzen
ubuntu@ubuntu_node:~$ ssh-keygen here two keys are generated /your_home/.ssh/id_rsa and /your_home/.ssh/id_rsa.pub . First one is private key and second is public key.
b. Copy the public key to authorized_keys on remote node(in my case a CentOS node) using ssh-copy-id
-
Carrige return(\r) addition to a file in Windows
1. Problem While writing a bash script in Unix, i found that if i create a file in Windows and use it it in a bash script, script fails. When digging deeper into the issue, i got to know that this was due to carriage return(\r), which was added when i modified the file in Windows(\r).
2. Basics In old days when people had to use Typewriters, they had to do two things frequently