HowTo Archives

How to reset your Linux Password

If you’ve ever forgotten your Linux password, chances are you’ve needed to either restore your Linux installation.  Hopefully this solution will save you from having to reinstall Linux in the event that you forget your password.

Reset your Linux password using Grub:

When your machine boots into Grub, you’ll want to press “e” to edit the grub boot linux.

After pressing “e”, navigate to the kernel line and add the word “single” to the end of the long string.

Press “b” to boot into single user mode.

You should then be taken directly to a root user shell, where you can then type passwd, and change your root password.

After you’ve reset your root password, type reboot at the shell to leave single user mode.

Popularity: 1% [?]

Here is a quick tip on how to display the top largest files and directories within my home directory:

# du -hs /home/adam/* | sort -nr | head

Cheers!

Popularity: 5% [?]

Here is a quick tip on how to run crontab every 5 minutes.

*/5 * * * * /home/adam/script.sh will execute script.sh every 5 minutes.

Also, here’s a quick guide to understaning the layout of cron:
# MIN HOUR DAYOFMONTH MONTH DAYOFWEEK COMMAND
5 * * * * echo 'Hello'

Also, the Crontab Man page

For further reading on Crontab check out Understand Cron Jobs in 5 Minutes

Popularity: 100% [?]

Quickzi: Find files over a certain size on Linux

Here’s a quick tip for finding files over 100M on Linux.

# find /home/adam/ -size +100M -exec ls -lh {} \; | awk '{print $5 , $8}'

Note that if you change 100M in the command you can find files with any size.   Also, replace /home/adam with any directory you wish.

Popularity: 6% [?]

How To Backup Your iPod Music on Linux

As an iPod owner and Linux user, there are a few options I have on Linux for managing my iPod music library. In my opinion, the best option available is gtkpod. One great option of gtkpod is the ability to backup your iPod music to your hard drive for free. The purpose of this guide is to explain a little about gtkpod and show you how to backup your iPod to your hard drive on Linux. I am using Ubuntu to back up my iPod music with gtkpod. gtkpod is available for any Linux distribution that is running gnome libraries and has X installed.

About gtkpod

gtkpod is a platform independent Graphical User Interface for Apple’s iPod using GTK2. It supports the first to fifth Generation including the iPod mini, iPod Photo, iPod Shuffle, iPod nano, and iPod Video.

What can gtkpod do?

  • Read your existing iTunesDB (i.e. import the existing contents of your iPod including playcounts, ratings and on-the-go playlists).
  • Add MP3, WAV, M4A (non-protected AAC), M4B (audio book), podcasts, and various video files (single files, directories or existing playlists) to the iPod. You need a third party product to download podcasts, like ‘bashpodder’ or ‘gpodder’
  • View, add and modify Cover Art
  • Browse the contents of your local harddisk by album/artist/genre by adding all your songs to the ‘local’ database. From there the tracks can be dragged over to the iPod/Shuffle easily.
  • Create and modify playlists, including smart playlists.
  • You can choose the charset the ID3 tags are encoded in from within gtkpod. The default is the charset currently used by your locale setting.
  • Extract tag information (artist, album, title…) from the filename if you supply a template.
  • Detect duplicates when adding songs (optional).
  • Remove and export tracks from your iPod.
  • Modify ID3 tags — changes are also updated in the original file (optional).
  • Refresh ID3 tags from file (if you have changed the tags in the original file).
  • Sync directories.
  • Normalize the volume of your tracks (uses mp3gain or the replay-gain tag)
  • Write the updated iTunesDB and added songs to your iPod.
  • Work offline and synchronize your new playlists / songs with the iPod at a later time.
  • Export your korganizer/kaddressbook/thunderbird/evocalendar/evolution/webcalendar… data to the iPod (scripts for other programs can be added).

Go here to download gtkpod directly. For installation instructions on Ubuntu, see below.

Installing and Configuring gtkpod on Ubuntu

# sudo apt-get install gtkpod

Next, open gtkpod by navigating to the Applications > Sound & Video menu and selecting gtkpod.

Select gtkpod from Gnome Menu


Now with gtkpod open, plug in your iPod via USB to your computer and power on the iPod. gtkpod should load your iPod automatically.

Screenshot of gtkpod main screen

Next, select what tracks you would like to back up to your computer by highlighting the tracks.

Once you have selected the tracks (note: you can select All then highlight all of your music if you want to back up your entire iPod) select File > Export Tracks From Database > Selected Tracks

gtkpod Export tracks from database

You then will be prompted to select where you would like to save the tracks. Choose a directory and click Save.

Now sit back and let gtkpod back up your iPod music.

Popularity: 15% [?]

Quickzi: Find out what ports are open on Linux

Heres a quick tip on how to find out what ports are open on your Linux computer without using a port scanner.

# netstat -anp --tcp --udp | grep LISTEN

Cheers!

Popularity: 19% [?]

Here is how to change the PostgreSQL root password from the Linux command line. Replace “root” with any user name to change any password. It is important to note that PostgreSQL does not have an actual “root” user name. The “postgres” user is the super-user for PostgreSQL.

# su postgres
# psql -d template1
template1=# ALTER USER postgres WITH PASSWORD '${POSTGRESQL_POSTGRES_PASSWORD}';

You can replace “postgres” with any user name.

Popularity: 42% [?]

Quickzi: How To Change MySQL Root Password

Here is how to change the mysql root password from the Linux command line. Replace “root” with any user name to change any mysql user password.

Change MySQL Password

# /etc/init.d/mysql stop
# mysqld --skip-grant-tables
# mysqladmin -u root password 'newpasswd'
# /etc/init.d/mysql start

Cheers!

Popularity: 6% [?]

10 Linux Commands You Probably Don’t Use

If you are a hard core systems administrator or Linux engineer you’ll probably recognize most of these Linux command line tricks. The following Linux command line tips are not typically used by your everyday Linux user.

Quickly Find a PID with pgrep

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.

pgrep ssh

This will list all PIDs associated with the ssh process.

Execute The Last Executed Command

The heading sounds a bit confusing but it’s exactly what it does.

!!

This will execute the last command you used on the command line.

Execute The Last Command Starting With..

If you want to execute a command a command from history starting with the letter S you can use the following:

!s

This will execute the last command used on the command line that started with s.

Run a Command Repeatedly and Display the Output

watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds. watch is very similar to tail.

watch -d ls -l

This will watch the current directory for any file changes and highlight the change when it occurs.

Save Quickly in VI/VIM

If you’re in a hurry, you can save and quit the file you’re editing in vi by exiting insert mode, holding shift, and hitting z twice.

Quickly Log Out of a Terminal

You can quickly log out of a terminal session by using: CTRL+D

Navigate to the Last Directory You Were In

cd - will take you to the last directory you were in.

Make Parent Directories the Smart Way

mkdir -p /home/adam/make/all/of/these/directories/ will create all directories as needed even if they do not exist. Why waste time doing something silly like: mkdir make ; cd make ; mkdir all ; cd all ; mkdir of ; cd of … you get the point. Use mkdir -p!

Delete the Entire Line

If you’ve just typed a long string of commands that you don’t need to enter anymore, delete the entire line by using: CTRL+U.

Set the Time stamp of a File

touch -c -t 0801010800 filename.c will show the time stamp as 2008-01-01 8:00. The format is (YYMMDDhhmm).

Can you think of any other Linux commands that are less known to the general Linux community?

Subscribe to my RSS feed here.

Popularity: 34% [?]

How To Speed Up Linux

The Wired How-To Wiki has some great tips on how to speed up Linux.

Most of the tips covered in this article involve using the command line and editing system files. Therefore, it goes without saying that you should be fairly comfortable with your command line skills before attempting any of these tweaks. However, if you’re new to Linux, these system tweaks can serve as excellent feet-wetting exercises.

The tips for speeding up Linux are broken down into the following categories:

  • Get Rid of Unnecessary Processes
  • Swap Less Often
  • Speed Up Your Applications
  • Things That Probably Won’t Help

Read more

Popularity: 3% [?]