Ubuntu How Do I: A Linux Q&A

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

User Questions

Q: Get rid of snapcraft spyware

A: Linux users that know what snapcraft is are not happy with Ubuntu forcing it on them. The procedure to get rid of Snap is explained in the section "Uninstall and Remove Snap" on the Snapcraft page.

Q: Get system info such as processor speed etc

A: Goto "Ubuntu Software Center" and install: hardinfo (System Profiler and Benchmark) "System Monitor" on some systems has a tab that says "System" before the Processes, Resources, and File System tab. On my system there was no System tab so I had to install hardinfo.

Q: How to check for bad sectors on system from GUI

A: Goto "Disks" which is the program name you type into the Ubuntu search. Just type "disks." Once the Disks utility opens you should select your hard drive from the left pane. In the upper right corner of the interface is a gear icon that says "More actions" click that and choose SMART Data & Self-Tests (a feature available for any modern S.M.A.R.T. enabled IDE/SATA drive). This works with a drive having that technology and Ubuntu having it enabled. The "Overall Assessment will denote the number of bad sectors. Click "Start Self-test" to refresh. An Extended test may take about 10 minutes for a drive around 80-120gb.

To more thoroughly check for bad sectors and even mark them as bad you can drop to console. You can perfrom a read-only test while the fs is mounted.

$ sudo badblocks -v /dev/sda1 

To mark the bad blocks so that Ubuntu doesnt use them...

write the location of the bad sectors into a file.

$ sudo badblocks /dev/sda > /home/user/badblocks

Feed the file into the FSCK command to mark these bad sectors as "unusable" sectors.

$ sudo fsck -l badblocks /dev/sda

Q: How to easily mount windows network shares on demand

A: An easy way to to go to Muon (add software) and install Smb4K. It is a versatile network discovery utility.

Q: Change desktop screen resolution in KDE Plasma 5?

A: Goto KMenu -> Settings -> System Settings and under "Hardware" choose "Display and Monitor" select "Display Configuration" which is an icon on the left. In the right pane, which looks very plain you will see a box labeled VGA with 3 small icons: back arrows, a star, and a box with green arrows pointing inwards. Click that third icon with the green arrows.

Q: How do I print to a PDF document from something like Libra Office?

Option 1: LibreOffice specific

A: LibreOffice has an option to Export to PDF built in. This solution is specific to this software.

File -> Export as PDF

This is the best way to create a PDF from a composition document. LibreOffice / OpenOffice will create a 100% native PDF file.

Option 2: cups-pdf

A: Install and activate cups-pdf service. Here are the commands:

sudo apt-get install cups-pdf

Now when you choose to print from software you will see a PDF option. A PDF of the printed page will then be available under your home directory, in a sub-directory named PDF. /home/user/PDF

On a typical installation it is common for cups-pdf to already be installed. This creates a virtual PDF printer. To select cups-pdf as the default printer go to System Settings -> Hardware -> Printers

This method is not recommended when using LibreOffice or OpenOffice because the cups-pdf driver fails to create a fully native PDF document. A paragraph of text might have some characters represented as text and other characters as images. Characters in words are not always spaced correctly. The rendering quality is not as good as it should be. The process is disappointingly glitchy. Use this method for software that doesn't have a built-in PDF export feature.

Option 3: kdeprint

A: You can substitute kprinter for lpr. This opens the KDE-print dialog, which includes an option to produce PDF. Works on Unity, Gnome, or KDE. In version 3.4.3 of KDE-print there is a printer drop down which allows selection of the printer to use. Select the printer labeled "Print to File (PDF)."

Option 4: print to Postscript and convert with ps2pdf

A: Choose to print to a file from the "Postscript/default" printer. Once the ps file is created, you can run ps2pdf to convert the Postscript file to PDF format.

Q: How can I compress a big PDF into a smaller efficient size?

A: A scanned document saved as PDF or one created with Gimp can be too large. You can use ghostscript to compress a PDF file from the command line without losing its quality.

ps2pdf big.pdf smaller.pdf

Q: How do I choose a graphic animated screensaver?

A: Screensavers were removed in Ubuntu 11.10. Ubuntu 12.04 has no screensavers, instead, the screen simply goes black when the system is idle for the set amount of time. You can ditch this screen blanking and install screensavers if you prefer the eye candy.

sudo apt-get remove gnome-screensaver

Install XScreenSaver and some additional screensaver packages with the following command:

sudo apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra

Get started by launching the Startup Applications utility from the Dash. Add a startup program with the following command. The name and comment here can be anything you like:

xscreensaver -nosplash

Q: How do I get the file manager to show the path?

A: Ubuntu 14.4 still uses Nautilus as the file manager, which is labeled simply as "Files" in the UI. When in Files you simply can press the forward slash key to view the path entry, however, this does not show the current path. Press CONTROL-L to show the path text entry with the current path visible.

Q: Set an alternative default file manager in Unity/Gnome?

A: Tired of Nautilus and have already installed an alternative such as PCManFM or Dolphin but when you click to open directories it still launches Nautilus? You can set a different file manager. Nautilus manages the desktop icons in Gnome (Ubuntu's desktop environment). According to Default File Manager in Gnome the process seems very complicated an involved. There are some other hacks to try.

sudo apt-get install exo-utils
exo-preferred-applications

This opens a program that will let you edit the default. Click the Utilities tab, and under File Manager, set your preference. Some report this works, some say it works after a reboot, some say it doesn't work at all.

Another hack, an ugly one, is to replace the nautilus binary with a symlink to your preferred file manager.

mv /usr/bin/nautilus /usr/bin/nautilus.bak
ln -s /usr/bin/pcmanfm /usr/bin/nautilus

Yeah that's ugly but it works.

Q: Disable "Search your computer and online resources" Unity HUD Dash

A: The icon in launcher "Search your computer and online resources" is actually called "Dash." To turn off the online search feature: System Settings-> Security & Privacy-> Search TAB. See "When searching in the Dash: Include online search results" and click to turn off. (verified on: 14.04)

Furthermore, on the Dash go to the second menu from the bottom left-> Applications lens. On the Filter Results go to Sources and deselect Software Center.

To bring the search box press Super Key.

Q: Disable Alt key makes Unity HUD Dash Search popup?

Isn't it annoying how pressing the Alt key makes Unity HUD Dash search popup over the top of your program?

A: Yes. Programs like Emacs make use of the Alt key. Having it activate the HUD search can interfere with programs like Emacs. Open the System Settings application and navigate to System Settings -> Keyboard -> Shortcuts -> Launchers. Now locate and click on "Key to show the HUD" and press the BACKSPACE key. This disables any key-press to show Search. You can still click on it with the mouse if you need it. This is one MAJOR Ubuntu Annoyance tamed. (verified on versions: 12.04 and 14.04)

Q: Create a link (shortcut) on the desktop

A: Simply dragging from Dash to the desktop does not work. Unity is designed so that you add frequently used application links onto the launcher. The launcher at the left side of the screen allows you to access common software and switch between then when multitasking. Applications you launch will appear on the launcher while running. To permanently attach an application to the launcher, right-click its launcher icon and select Lock to Launcher.

Open Nautilus and navigate to /usr/share/applications. Now right-click on the application you want to make a link point to and select "copy." Click on your desktop and select paste. You may have to right click and under permissions set it to execute, depending on permissions factors.

  • /usr/share/applications

The files in /usr/share/applications all end with the extension .desktop. These files have two basic functions, they tell the desktop environment how the file is to be handled with regards to menu placement, display, environmental variables, and other related aspects. In doing so they reside globally in /usr/share/applications/ and for specific users in ~/.local/applications. Another function of the .desktop files is to be shortcuts on the desktop. When they are on the desktop they reside in ~/Desktop.

  1. /usr/share/applications/
  2. ~/.local/applications ( $home/.local/applications )
  3. ~/Desktop ( $home/Desktop )

If the software doesn't have an associated .desktop file then you will have to manually create it using the correct syntax. Although you can make symbolic links to directories on your desktop by placing the symbolic link in ~/Desktop you should not create symbolic links directly to binaries. Instead of making symlinks to binaries, use the .desktop file convention.

Q: How do I Hide & Unhide the Unity Launcher in Ubuntu 14.04?

A: Launcher automatically hide: click the system menu in the upper-right corner of the screen on the top panel. Select "System Settings" from the drop-down menu.

Move the mouse to the left of the screen to reveal Launcher. Press the Super Key to reveal Launcher. Press and hold down Super Key to reveal launcher, and also show a list of all Unity Keyboard Shortcuts.

From virtualbox or from a VNC client you cannot unhide Launcher by moving the mouse to the left of the screen. Alt-F1 will unhide the Launcher and put it in keyboard navigation mode. However, you can still use the mouse to select icons that are visible in the Launcher. You can also use the up and down arrow keys to traverse the Launcher. The downside is that you can't navigate down to any hidden icons with the mouse. credit to: Christopher Townsend

Q: How do I safely remove a USB drive to not risk data loss?

This question relates to the well known feature in Microsoft Windows where you should click on "Safely Remove Hardware" in the icon tray and choose "Safely remove USB Mass Storage Device." A: Some versions of Ubuntu Unity only offered safely remove and eject as options. As of 14.04 you can select the USB device from the left menu in Nautilus and find an option to "Safely Remove Drive." See illustration:

Ubuntu-unity-saferemoveusb.png

Ubuntu 12.10 is missing the "Safely Remove Drive" option, instead offering only "Unmount" or "Eject" - you can use a console alternative. From the command line you can determine your USB device

mount -l
udisks --unmount /dev/sdb1 && udisks --detach /dev/sdb

Calling udisks --detach on the device checks that you have no filesystems mounted on that device.

Q: What's the difference between unmount and safely remove?

A: Flash drives and Pen Drives need to be synchronized before unmounted to prevent loss of data.

  • Unmount - For Hard Drives
  • Eject - For Optical Drives
  • Safely Remove - For USB Drives that need sync and power down

Instead of directly writing to disk, data is written to a buffer where it is cached and the process moves on. Data is later synchronized to the disk. This speeds up applications so a process is not waiting on i/o activity. With the remove safely option, data is cleared from the buffer and written to disk, which reduces chances of data loss. The act of flushing the memory buffer and writing to disk is the synchronization. USB devices need to be synced and a moment for resonant voltage to clear before data is considered safe prior to removal of the device. Because modern versions of Microsoft Windows automatically disables caching on USB devices the act of choosing the safely remove drive is merely an extra precaution that isn't necessary on most systems. With Linux it all depends on how the drive was mounted. Also note that the safe removal and unmounting a removable drive ensures that no application has a file open.

Q: What's my Ubuntu version?

A: Type this at console:

cat /etc/apt/sources.list|grep Release

Q: How do I monitor disk i/o activity?

A: You can find out what process is generating disk read and write activity with a program called iotop. When the hard drive light is flashing and you want to determine the process causing it simply install and run iotop. This can also be useful for helping to detect a system intrusion.

sudo apt-get install iotop
sudo iotop

Looks just like "top" except shows processes based on amount of disk activity each process is generating.

Q: How do I set a static IP address in Ubuntu Unity

A: The main problem people face is when in the Network Manager GUI interface after entering the IP address information the save button is gray. Typically this is because the user entered "255.255.255.0" or a similar netmask. Because the unity programmers were assholes, you have to use the format "24" rather than entering the netmask the long way. See the following link on this wiki for full details on using Unity Network Manager: http://wiki.robotz.com/index.php/Ubuntu_Customization#IP_Network_Configuration_.28GUI_-_Network_Manager.29

Q: How do I run graphical programs as sudo?

A: The correct way to run graphical programs with elevated privileges is by using the following:

  1. gksu - equivalent to su except in gui rather can console
  2. gksudo - equivalent to sudo except in gui rather than console

You can install gksu and gksudo in Ubuntu from the command line:

   sudo apt-get install gksu

Related

External Resources