HowTo Archives
6 Tricks with AWK
Quickzi: Replace all spaces with a dot in vim
Here’s a quick tip on how to replace all spaces with a dot in vim:
:%s/[ \t]/./
And here’s how to remove all trailing spaces at the end of each line:
:%s/\s\+$//
Have any more vim quick tips? Let’s hear them in the comments.
Popularity: 1% [?]
Quickzi: Find files older than 5 days
Here’s a quick command line tip to find files older than 5 days, and execute an action on those files:
find /home/foo/* -mtime +5 -exec echo {} > oldfiles.txt \;
&& mail -s "files older than 5 days" foo@foogazi.com < oldfiles.txt
This command searches for files that are older than 5 days, and sends the output to oldfiles.txt, then an email is sent to foo@foogazi.com with a list of the old files.
Alternatively, you could search for files older than 5 days, then delete them using this command:
find /home/foo/* -mtime +5 -exec rm {} \;
Popularity: 1% [?]
Linux How To Reset Gnome Settings in Ubuntu
Have you ever messed around with your Ubuntu Gnome settings only to find out you broke something? Here is a quick write up on how to reset your gnome settings in Ubuntu.
In short, you basically need to delete these from your home directory: ~/.gnome ~/.gnome2 ~/.gconf ~/.gconfd ~/.metacity
Popularity: 2% [?]
How to boot into a specific Linux runlevel by default
If you don’t already know, a runlevel is what Linux uses as a mode of operation. A ‘runlevel’ defines the state of the operating system after power on.
Typically, Linux runlevels look like the following:
- 0 – Halt (shutdown)
- 1 – Single-User mode
- 2-5 – Full multi-user mode with console logins and display manager if it’s installed
- 6 – Reboot
On most Linux servers, the default runlevel will be set to runlevel 3. Multi-user mode and console logins only. Whereas, most Linux desktops, the default runlevel will be set to runlevel 5.
If you want to boot into a specific runlevel every time your computer turns on, all you need to do is edit the /etc/inittab. For this example, we will change the runlevel from 3 to 5.
# vi /etc/inittab
Modify the line that looks like this:
id:3:initdefault:
And change the number 3, to 5.
id:5:initdefault:
Save the file. Next time you reboot Linux will boot directly into your desktop window manager.
Popularity: 2% [?]
Free Linux Backup Software: Lucky Backup
Jack Wallen has a great Linux how-to on using the Linux backup software, Lucky Backup, to backup and store your data.
I’ve used Lucky Backup in the past and can attest that it is very easy to use, and has all the features you need for a good backup system.
Some of the features include:
- Snapshot backups
- Sync directories
- Exclude directories/files
- Profiles
- Scheduling
- Logging
- Command line mode
Head over and read Jack’s how to. He does a great job showing just how easy it is to use.
Popularity: 2% [?]
How to record your Linux shell session
A lot of people are probably not aware of the command script. Script is a quick and easy way to record everything you do in a terminal session. I use script to record sessions of me fixing a server, or troubleshooting Linux issues, and save it for future needs, or to pass on to others as training material. Here is what the Linux man page says:
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
Using script to record your terminal session
It’s really quite simple to record your bash session. All you need to do is type script -a filename to start recording your session:
Now that the recording has started, everything you type, as well as everything that returns as output, will be saved into the filename you chose to output to.
Popularity: 16% [?]
Linux rename user command
I’ve gotten this question a whole bunch of times in the past. You’ve got a Linux username that you want to rename, rather than recreate, so you don’t lose any significate data or permission settings. How do you rename a Linux user?
Linux rename user command
To rename a Linux user (rename user name), you want to use the Linux command usermod. From the man page:
The usermod command modifies the system account files to reflect the changes that are specified on the command line.
In short, here is the command to rename the Linux user:
usermod -d "/home/current_user-name" -m -l current_user_name new_user-name
And now an explanation of what each option means:
- -d specifies the current users home directory.
- -m specifies that you want to move the files from the current users home directory, to the new directory. You want to make sure you specify this, otherwise the users data will not transfer over to the new user account.
- -l specifies the current user name, and the new user name you wish to change it to.
That’s it. Now you’ve renamed a Linux user.
Popularity: 4% [?]
How to configure static IP on Ubuntu
Do you use Ubuntu and wish to set a static IP for your machine? It’s simple. Follow the steps below to find out how.
- Right click the network manager icon at the top right of your desktop
- Select Edit Connections
- Select Wired
- Click the EDIT button
- Click the IPv4 settings tab
- Select Manual from the method drop down list
- Click the ADD button to add your static IP address
- Add your DNS addresses in the DNS servers field. You can separate each DNS entry with a comma
- Click OK.
- Restart networking using this command:
/etc/init.d/networking restart
Popularity: 1% [?]












