TOPIC: SUDO
Setting up MySQL on Sabayon Linux
27th September 2012For quite a while now, I have offline web servers for doing a spot of tweaking and tinkering away from the gaze of web users that visit what I have on there. Therefore, one of the tests that I apply to any prospective main Linux distro is the ability to set up a web server on there. This is more straightforward for some than for others. For Ubuntu and Linux Mint, it is a matter of installing the required software and doing a small bit of configuration. My experience with Sabayon is that it needs a little more effort than this, so I am sharing it here for the installation of MySQL.
The first step is to install the software using the commands that you find below. The first pops the software onto the system while the second completes the set-up. The --basedir
option is need with the latter because it won't find things without it. It specifies the base location on the system, and it's /usr
in my case.
sudo equo install dev-db/mysql
sudo /usr/bin/mysql_install_db --basedir=/usr
With the above complete, it's time to start the database server and set the password for the root user. That's what the two following commands achieve. Once your root password is set, you can go about creating databases and adding other users using the MySQL command line
sudo /etc/init.d/mysql start
mysqladmin -u root password 'password'
The last step is to set the database server to start every time you start your Sabayon system. The first command adds an entry for MySQL to the default run level so that this happens. The purpose of the second command is to check that this happened before restarting your computer to discover if it really happens. This procedure also is necessary for having an Apache web server behave in the same way, so the commands are worth having and even may have a use for other services on your system. ProFTP is another that comes to mind, for instance.
sudo rc-update add mysql default
sudo rc-update show | grep mysql
Getting rid of a Dropbox error message on a Linux-powered PC
24th September 2012One of my PC's has ended up becoming a testing ground for a number of Linux distributions. The list has included openSUSE, Fedora, Arch and LMDE with Sabayon being the latest incumbent. From Arch onwards in that list, though, a message has appeared on loading the desktop with every one of these when I have Dropbox's client set up on there:
Unable to monitor entire Dropbox folder hierarchy. Please run "echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches" and restart Dropbox to correct the problem.
Even applying the remedy that the message suggests won't permanently resolve the issue. For that, you need to edit /etc/sysctl.conf
with superuser access and add the following line to it:
fs.inotify.max_user_watches = 100000
With that in place, you can issue the following command to sort out the problem in the current session (assuming your user account is listed in /etc/sudoers
):
sudo sysctl -p & dropbox stop & dropbox start
A reboot should demonstrate that the messages no longer appear again. For a good while, I had ignored it, but curiosity eventually got me to find out how it could be stopped and led to what you find above.
Listing hardware information for Linux systems
3rd August 2012Curiosity about the graphics card on my backup PC caused me to look for ways of getting this information without opening up the machine or searching for a manual. In the end, a solitary command did the job:
sudo lshw
If you are running it as root, the sudo
piece can be dropped, but the result is the same. As it happened, it provided me with the information that I needed.
Changing from to Nvidia Graphics Drivers on Linux Mint Debian Edition 64-bit
22nd April 2012One way of doing this is to go to the Nvidia website and download the latest file from the relevant page on there. Then, the next stage is to restart your PC and choose rescue mode instead of the more usual graphical option. This drops you onto a command shell that is requesting your root password. Once this is done, you can move onto the next stage of the exercise. Migrate to the directory where the *.run file is located and issue a command similar to the following:
bash NVIDIA-Linux-x86_64-295.40.run
The above was the latest file available at the time of writing, which may have changed by the time that you read this. If the executable asks to modify your X configuration file, I believe that the best course is to let it do that. Editing it yourself or running nvidia-xconfig
are alternative approaches if you so prefer.
Since proprietary Nvidia drivers are included in the repositories for Linux Mint Debian Edition, that may be a better course of action since you will get updates through normal system update channels. Then, the course of action is to start by issuing the following installation commands:
sudo apt-get install module-assistant
sudo apt-get install nvidia-kernel-common
sudo apt-get install nvidia-glx
sudo apt-get install kernel-source-NVIDIA
sudo apt-get install nvidia-xconfig
Once those have completed, issuing the following in turn will complete the job ahead of a reboot:
sudo m-a a-i nvidia
sudo modprobe nvidia
sudo nvidia-xconfig
If you reboot before running the above like I did, you will get a black screen with a flashing cursor instead of a full desktop because X failed to load. Then, the remedy is to reboot the machine and choose the rescue mode option, provide the root password and issue the three commands (at this point, the sudo prefix can be dropped because it's unneeded) then. Another reboot will see order restored and the new driver in place. Running the following at that point will do a check on things, as will be the general appearance of everything:
glxinfo | grep render
Synchronising package selections between Linux Mint and Linux Mint Debian Edition
18th April 2012To generate the package list on the GNOME version of Linux Mint, I used the Backup Tool. It simply was a matter of using the Backup Software Selection button and telling it where to put the file that it generates. Alternatively, dpkg can be used from the command line like this:
sudo dpkg --get-selections > /backup/installed-software.txt
After transferring the file to the machine with Linux Mint Debian Edition, I tried using the Backup Tool on there too. However, using the Restore Software Selection button and loading the required only produced an irrecoverable error. Therefore, I set to looking around the web and found a command line approach that did the job for me.
The first step is to load the software selection using dpkg by issuing this command (it didn't matter that the file wasn't made using the dpkg command, though I suspect that's what the Linux Mint Backup Tool was doing that behind the scenes):
sudo dpkg --set-selections < /backup/installed-software.txt
Then, I started dselect
and chose the installation option from the menu that appeared. The first time around, it fell over but trying again was enough to complete the job. Packages available to the vanilla variant of Linux Mint but not found in the LMDE repositories were overlooked as I had hoped, and installation of the extra packages had no impact on system stability either.
sudo dselect
Apparently, there is an alternative to using dselect
that is based on the much used apt-get command, but I didn't make use of it so cannot say more:
sudo apt-get dselect-upgrade
All that I can say is that the dpkg/dselect
combination did what I wanted, so I'll keep them in mind if ever need to synchronise software selections between two Debian-based distributions in the future again. While the standard edition of Linux Mint may be based on Ubuntu rather than Debian, Ubuntu is itself based on Debian. Thus, the description holds here.
Adding GNOME 3 to Linux Mint 11
3rd June 2011On the surface of it, this probably sounds a very strange thing to do: choose Linux Mint because they plan to stick with their current desktop interface for the foreseeable future, and then stick a brand new one on there. However, that's what last weekend's dalliance with Fedora 15 caused. Not only did I find that I could find my way around GNOME Shell, but I actually got to like it so much that I missed it on returning to using my Linux Mint machine again.
The result was that I started to look on the web to see if there was anyone else like me who had got the same brainwave. In fact, it was Mint's being based on Ubuntu that allowed me to get GNOME 3 on there. The task could be summarised as involving three main stages: getting GNOME 3 installed, adding extensions and adding the Cantarell font that is used by default. After these steps, I gained a well-running GNOME 3 desktop running on Linux Mint, and it looks set to stay that way unless something untoward emerges.
Installing GNOME 3
The first step is to add the PPA repository for GNOME 3 using the following command:
sudo add-apt-repository ppa:gnome3-team/gnome3
The, it was a case of issuing my usual update/upgrade command:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
When that had done its thing and downloaded and installed quite a few upgrades along the way, it was time to add GNOME Shell using this command:
sudo apt-get install gnome-shell
When that was done, I rebooted my system to be greeted by a login screen very reminiscent of what I had seen in Fedora. While compiling this piece, I noticed that GNOME Session could need to be added before GNOME Shell, but I do not recall doing so myself. Maybe dependency resolution kept any problems at bay, but there weren't any issues that I could remember beyond things not being configured as fully as I would have liked without further work. For the sake of safety, it might be a good idea to run the following before adding GNOME Shell to your PC.
sudo apt-get install gnome-session && sudo apt-get dist-upgrade
Configuration and Customisation
Once I had logged in, the desktop that I saw wasn't at all unlike the Fedora one and everything seemed stable too. However, there was still work to do before I was truly at home with it. One thing that was needed was the ever useful GNOME Tweak Tool. This came in very handy for changing the theme that was on display to the standard Adwaita one that caught my eye while I was using Fedora 15. Adding buttons to application title bars for minimising and maximising their windows was another job that the tool allowed me to do. The command to get this goodness added in the first place is this:
sudo apt-get install gnome-tweak-tool
Since the next thing that I wanted to do was add some extensions, I added a repository from which to do this using the command below. Downloading them via Git and compiling them just wasn't working for me, so I needed another approach.
sudo add-apt-repository ppa:ricotz/testing
With that is place, I issued the following commands to gain the Dock, the Alternative Status Menu and the Windows Navigator. The second of these would have added a shutdown option in the me-menu, but it seems to have got deactivated after a system update. Holding down the ALT key to change the Suspend entry to Power off... will have to do me for now. Having the dock is the most important and that, thankfully, is staying the course and works exactly as it does for Fedora.
sudo apt-get install gnome-shell-extensions-dock
sudo apt-get install gnome-shell-extensions-alternative-status-menu
sudo apt-get install gnome-shell-extensions-windows-navigator
Adding Cantarell
The default font used by GNOME 3 in various parts of its interface is Cantarell, and it was defaulting to that standard sans-serif font on my system because this wasn't in place. That font didn't look too well, so I set to tracking the freely available Cantarell down on the web. When that search brought me to Font Squirrel, I downloaded the zip file containing the required TTF files. The next step was to install them and, towards that end, I added Fontmatrix using this command:
sudo apt-get install fontmatrix
That gave me a tool with a nice user interface, but I made a mistake when using it. This was because I (wrongly) thought that it would copy files from the folder that I wanted the import function to use. Extracting the TTF files to /tmp
meant that would have had to happen, but Fontmatrix just registered them instead. A reboot confirmed that they hadn't been copied or moved at all, and I had rendered the user interface next to unusable through my own folly; the default action on Ubuntu and Linux Mint is that files are deleted from /tmp
on shutdown. The font selection capabilities of the GNOME Tweak Tool came in very handy for helping me to convert useless boxes into letters that I could read.
Another step was to change the font line near the top of the GNOME Shell stylesheet (never thought that CSS usage would end up in places like this...) so that Cantarell wasn't being sought and text in sans-serif font replaced grey and white boxes. The stylesheet needs to be edited as superuser, so the following command is what's needed for this and, while I used sudo, gksu
is just as useful here if it isn't what I should have been using.
sudo gedit /usr/share/gnome-shell/theme/gnome-shell.css
Once I had extricated my system from that mess, a more conventional approach was taken and the command sequence below was what I followed, with extensive use of sudo to get done what I wanted. A new directory was created and the TTF files copied in there.
cd /usr/share/fonts/truetype
sudo mkdir ttf-cantarell
cd ttf-cantarell
sudo mv /tmp/*.ttf .
To refresh the font cache, I resorted to the command described in a tutorial in the Ubuntu Wiki:
sudo fc-cache -f -v
Once that was done, it was then time to restore the reference to Cantarell in the GNOME Shell stylesheet and reinstate its usage in application windows using the GNOME Tweak Tool. Since then, I have suffered no mishap or system issue with GNOME 3. Everything seems to be working quietly, and I am pleased to see that replacement of Unity with the GNOME Shell will become an easier task in Ubuntu 11.10, the first alpha release of which is out at the time of my writing these words. Could it lure me back from my modified instance of Linux Mint yet? While I cannot say that I am sure of those, but it certainly cannot be ruled out at this stage.
Taking the sudo command beyond Ubuntu
27th October 2010Though some may call it introducing a security risk, being able to execute administrator commands on Ubuntu using sudo and gksu by default is handy. It's not the only Linux distribution with the facility, though, since the /etc/sudoers
file is found in Debian and I plan to have a look into Fedora. The thing that needs to be done is to add the following line to the aforementioned file (you will need to do this as root):
[your user name] ALL=(ALL) ALL
One that is done, you are all set. Just make sure that you're using a secure password, though, and removing the sudo/gksu permissions is as simple as reversing the change.
Update on 2011-12-03: The very same can be done for both Arch Linux and Fedora, The same file locations apply too.
Enabling DVD playback in Ubuntu 9.04
22nd July 2009This information is scattered about the web, so I decided to collect something together in one place in case it helps anyone else. Here are two commands that appeared to do the deed for me:
sudo apt-get install ubuntu-restricted-extras totem-xine libxine1-ffmpeg libdvdread4
sudo /usr/share/doc/libdvdread4/install-css.sh
The libdvdread
piece is what sorts out encrypted disks and needs a two stage installation, hence the second command. For non-encrypted disks, ubuntu-restricted-extras
might be all that's needed if my experience is typical. Taking things further, Wim Wenders' Buena Vista Social Club (Region 2 disk) worked when I tried it, too. In the interests of completeness, I tried the command combination on a virgin 9.04 installation with restricted and multiverse repositories enabled. Along the way, I spied a whole raft of helper components being set in place, and things worked like I would have expected with the aforementioned DVD afterwards. As with anything related to computing, your mileage may vary and, for more information, you can have a look here.
Removing files for which you have no write access from the GNOME Wastebasket in Ubuntu 8.04
2nd September 2008It might be that GNOME contains a small trap awaiting the unwary: moving files for which you have no write permissions to the Wastebasket using Nautilus. This happened to me in Ubuntu 8.04 which meant that I couldn't clear the Wastebasket using the normal means. To resolve the situation, I thought of finding where the Wastebasket in the normal file system, and that isn't as easy as it might be. One place to look is ~/.Trash
, but I didn't have that at all because the location in Hardy Heron is ~/.local/share/Trash/Files
. Armed with this knowledge, I turned to the command line and performed the required erasure using sudo. It was all over soon enough once I knew where to look.
A quick way to do an update
8th August 2008Here's a quick way to get the latest updates on your PC using the command line if you are using Ubuntu or Debian:
sudo apt-get update && sudo apt-get upgrade
Of course, you can split these commands up if you prefer to look before you leap. At the very least, it's so much slicker than the GUI route.