Quickzi: Disable Login and Logout Sound on Ubuntu

I don’t know about you but I find the login sound on Ubuntu pretty annoying. Here is a quick, nice and easy way to disable it.

How to disable Ubuntu Login and Logout sounds

Navigate to System > Preferences > Sound then click the Sounds tab.

Disable Login and Logout Sound on Ubuntu

Set the Log Out and Log In sounds to “No Sound” to disable the login and logout sounds in Ubuntu.

The Best Way To Learn Linux

Dan Craciun posted a nice article on his blog titled What is the best way to learn linux? that got me thinking just what some of the best ways to learn Linux are.  Dan and I agree that reading documentation is one of the best ways to learn Linux in general.

Dan uses the famous quote “give a man a fish and he will have food for one day, teach the same man how to fish and he will have food for his entire life” which really does make sense in relation to learning Linux.  A lot of new Linux users will ask a question on a forum or in an IRC chat room and demand or expect a direct answer.  However, a lot of times what they end up getting is a way to solve their problem, not exactly how to do it.  There is a general consensus among old time and advanced Linux users that it’s important to read documentation and manuals if you want answers.

Here are some of the best ways to learn Linux:

  • Start off on the command line to learn the true way of Linux before you start on the desktop and use GUI tools to do everything for you.  Remember each GUI tool you use is just a front end for command line tools that can accomplish the same thing.
  • Read manuals and ask a lot of questions.  Be sure you’re asking the right questions though. Research before you ask.  Don’t bother to ask questions to something that you could easily find by spending 5 minutes searching Google.
  • Subscribe to Linux blogs and participate in Linux forums.
  • Explore your options by trying different Linux distributions.

Quickzi: How To Delete Bash History

If you want to delete your bash history, there are a few options you have.  First you must understand that the history of your bash session is stored into RAM and then written to ~/.bash_history when you log out of the bash session.  So even if you delete the ~/.bash_history file, your current bash session will still be written to history once you log out.

Delete bash history

To delete the bash history for your current session as well as old sessions, you should do two things:

Delete the .bash_history file:

# rm -rf ~/.bash_history

Clear the current history stored in RAM:

# history -c

Stop writing to .bash_history for good

If you don’t want to log any history for good, you can do one of two things; turn it off for all users, or turn off logging history for a single user.

Turn off bash history for all users:

Append “unset HISTFILE” to /etc/profile:

# echo "unset HISTFILE" >> /etc/profile

Turn off bash history for a specific user:

Append “unset HISTFILE” to /home/USER/.bash_profile:

# echo "unset HISTFILE" >> /home/USER/.bash_profile

That’s it! Now you have successfully deleted the bash history and stopped logging to bash history.

Quickzi: How To Replace a Line in a Text File

Here is a quick tip on how to use sed to replace a line in a text file from the command line, without opening it.

Replace a Line in a File

First, replace the text you want with sed and output it into a temporary file to ensure that it is correct:

# sed -e 's/original-text/new-text/' textFile > newFile

View the newFile and make sure that the line is correctly replaced:

# more newFile

Overwrite the textFile with the newFile:

# mv newFile textFile

Quickzi: How To Add a Line into the middle of a Text File

Here is a quick tip on how to use sed to add a line into the middle of a text file from the command line, without opening it.

To clarify, let’s say you have a text file that has four lines:

Line1Text
Line2Text
Line3Text
Line4Text

Using sed, you can append a line anywhere you want with a simple command without even knowing the line numbers.

Add a Line into the Middle of a Text File

For this example, lets say we want to append a new line under Line3Text:

# sed '/^Line3Text/a NewLineText' textFile > newFile

You’ll notice that we output the results to a newFile so that we can make sure the new line appended correctly before overwriting the original file.  If you check the newFile, you should see a correct output, then you can overwrite the original textFile.

# mv newFile textFile

MySQL Change Password Tip

I keep getting the question on how to change a mysql root password. Here is a quick tip on how to change the MySQL password from the command line.

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

Change MySQL Password for a standard user

You can also change the mysql password for a standard user using mysqladmin.

# mysqladmin -u username -p oldpass newpass

Linux Vocabulary for the New Linux User

If you’re just starting out with using Linux then chances are you’ve probably seen or heard a few Linux terms that you don’t recognize. It’s typical that when you ask, or search, for help on the Internet for Linux, you’ll see some of the following terms. I’ve put them in one place for you so that the next time you see a Linux vocabulary word you don’t know, you can check back here.

APT – Advanced Packaging Tool. APT simplifies the process of managing packages on Linux by automating the retrieval, configuration and installation. Generally, you’ll find APT on a Debian or Ubuntu distro.

BashBourne Again Shell is generally the default shell in most Linux distributions. When someone refers to a shell or the command line the Bash shell is usually what they are referring to.

CLI – The CLI is known as the Command Line Interface.  When you open a terminal, or if you do not use a Window Manager, or X11, you are operating on the CLI.

Dependency – A application, library, or development set that a package depends upon to work.

Distro – Short for Distribution, a distro is a set of programs combined with the Linux kernel to create an Operating System.

GNOME - Can be called a “complete” desktop environment for Linux. Gnome is the default desktop on the popular Ubuntu distribution.

GRUB – Another boot loader for Linux. Allows users to have several different Operating Systems on their system at once, and choose which one to run when the computer starts.

KDE- KDE or the K Desktop Environment, is desktop environment for Linux workstations.

Kernel – The core, or “brain” of Linux. The kernel is what controls the hardware and is what every Linux distro is built upon.

LILOLinux LOader. Similar to Grub, LILO is a boot loader for Linux. LILO usually writes to the Master Boot Record (MBR) on your device.

Linus Torvalds – The man who wrote the Linux kernel in 1991.

Man – Short for manual. If someone says “read the man page” or “rtfm” when you ask a question about a command, they want you to type “man command”.

Root – The superuser account on all Linux systems.

RPM – A package manager, which can be used to build, install, query, verify, update, and erase individual software packages. RPM is used by default on the Red Hat and Fedora distributions.

Sudo – Stands for Super User DO, allows a user to have root access without logging in as root.

Tux – The Linux Penguin

YAST – Stands for Yet Another Setup Tool.  Typically used on the SuSE distro.  Yast is a setup and configuration tool.

YUM - An automated update program which can be used for maintaining systems using rpmYum is also used on Red Hat and Fedora by default.

X / X11- Also known as the X Window System, X is a windowing system that provides the standard toolkit and protocol with which to build graphical user interfaces (GUIs).  KDE and GNOME are built upon X11.

Can you think of any other vocabulary words for Linux newbies that should be on this list?  Please, share your ideas in the comments below.

Quickzi: How To Log Boot Messages in Ubuntu

Here is a quick Linux tip to log your boot messages in Ubuntu.  This is great for checking for any errors or failed startups that may be happening during boot.

Edit /etc/default/bootlogd:

# vi /etc/default/bootlogd

You’ll see the following lines:

# Run bootlogd at startup ?
BOOTLOGD_ENABLE=No

Change No to Yes:

# Run bootlogd at startup ?
BOOTLOGD_ENABLE=Yes

Now every time your computer restarts, a /var/log/boot file will be created.

Quickzi: Find out what IPs are on your subnet

Here is a quick tip on how to find out what host IPs are on your subnet using nmap. This is useful to find out what IPs are being used or just to know how many devices are connected to the subnet.

How to find out what IPs are being used on your subnet

# nmap -v -sP 192.168.1.0/24

You can replace the 192.168.1.0/24 address with whatever your IP and subnet is.

Also, for a cleaner output that removes the lines that tell you an IP is not used, try the following:

# nmap -v -sP 192.168.1.0/24 | grep -v "appears to be down"

Quickzi: How to Disable The System Beep in Ubuntu

If you’re looking to get rid of the annoying system beep in Ubuntu, here is how to do it from both the command line, and from the Gnome desktop.

Disable the System Beep from the Command Line

#sudo vi /etc/modprobe.d/blacklist

And then add:

#pc speaker beep

blacklist pcspkr

Save and quit the file:

:wq

Now, remove the pcspkr module:

sudo rmmod pcspkr

Disable the System Beep in Ubuntu from the Gnome Desktop

This way is much easier.  Simply navigate to System -> Preferences -> Sound then navigate to the System Beep tab.  Uncheck the box labeled “Enable the System Beep” and click close.

Disable the System Beep from the Ubuntu Desktop