So you are Admin-ing away, and you are following SOP and making backups of all the files you edit. Right? However, as you have 100 servers to do and 5 files on each, that is a lot of typing! You become lazy and forget the backup on one file, and then it happens. A reboot hangs and you have no idea why, except that you were just editing system files...
Here is a quick way to backup any file:
cp /path/to/file{,.bak}
Example:
cp /etc/fstab{,.bak.2012-01-30}
The above example will produce a file named: /etc/fstab.bak.2012-01-30
This may seem a trivial savings in typing, but when you are scripting or in a hurry it can be a great time saver. It also protects the backup file name from any typos.
Make those backups and save yourself the frustration of having to go into single user to fix it! Better procedures equal less downtime.
Yep. I forget things. I love to learn new things, but sometimes, I can't quite remember how I did them. Feel free to use this repository as I do: A vault of things I want to remember...
Monday, January 30, 2012
Wednesday, January 25, 2012
Command to see info on GPG key
Command to see info on GPG key
rpm -q --qf "%{NAME}-%{VERSION}-%{RELEASE} \n %{SUMMARY} \n" gpg-pubkey
rpm -q --qf "%{NAME}-%{VERSION}-%{RELEASE} \n %{SUMMARY} \n" gpg-pubkey
Operate on data input from the command line
So you want to quickly sort a list without going through a lot of steps. This is what was happening to me, and I found a quick and easy way to do that from the command line. This technique will work for any other operation that you want to preform as well.
Here is the command:
cat << EOF | sort [enter]
[enter text here]
EOF [enter]
The [enter text here] will then be output to the command line sorted. You can get very fancy with this technique. This comes in handy when you have a set of text already stored in the copy buffer (clipboard). Then you can just copy and paste into the [enter text here] section and very quickly have your desired operation.
Here is another example:
cat << EOF |sort > test [enter]
[enter text here]
EOF [enter]
This does the same thing, but puts the results into a file called 'test'. Obviously you can get very creative with this. Then again, if you are going crazy with this a small shell script may be better. Then again, small shell scripts can replace many of us... :)
Here is the command:
cat << EOF | sort [enter]
[enter text here]
EOF [enter]
The [enter text here] will then be output to the command line sorted. You can get very fancy with this technique. This comes in handy when you have a set of text already stored in the copy buffer (clipboard). Then you can just copy and paste into the [enter text here] section and very quickly have your desired operation.
Here is another example:
cat << EOF |sort > test [enter]
[enter text here]
EOF [enter]
This does the same thing, but puts the results into a file called 'test'. Obviously you can get very creative with this. Then again, if you are going crazy with this a small shell script may be better. Then again, small shell scripts can replace many of us... :)
Subscribe to:
Posts (Atom)