Ubuntu Tips

From wikidb
Jump to: navigation, search

ifconfig

Display status of current networks.

I forget this simple command sometimes.

bashrc prompt

 case "$TERM" in
 xterm*|rxvt*)
   PS1="\u@\h:\W$ "
   ;;
 *)
 ;;
 esac

Run Levels

runlevel
 
telinit 3

Install

 sudo aptitude search phidget

Each search result is listed on a separate line.

  • The first character of each line indicates the current state of the package: Aptitude Man Page
    • i: Installed package
    • c: Package not installed, but package configuration remains on system
    • p: Purged from system
    • v: Virtual package
    • B: Broken package
    • u: Unpacked files, but package not yet configured
    • C: Half-configured - Configuration failed and requires fix
    • H: Half-installed - Removal failed and requires fix
  • The second character indicates the stored action (if any; otherwise a blank space is displayed) to be performed on the package,
    • i, the package will be installed,
    • d, the package will be deleted, and
    • p, the package and its configuration files will be removed.
  • If the third character is
    • A, the package was automatically installed.

The follow provides some of the above info

 apt-cache search opencv
  • Detailed description of a package
 apt-cache show opencv-do
  • List the files in a package
 dpkg -L opencv-doc
  • Find the package a file is in
 dpkg -S highgui.h
  • Remove unneeded packages
 apt-get autoremove
  • Get source
 apt-get source phidget
  • Find installed and look for specific
 apt list --installed | grep adb

or

 dpkg -l android-tools-ad
  • Upgrade a specific package
  sudo apt-get install --only-upgrade android-tools-adb

Update

 sudo apt-get update
 
 sudo apt-get dist-upgrade

See also the Software Updater in Preferences menu

Git

cmake

There is not cmake clean. Remove the build directory you ran cmake in.

Text Mode for Ubuntu 14.04

Reference

Boot Into Text Mode

Text Mode Login

Setup for text boot. First backup the grub file.

 cd /etc/default/
 sudo cp -n grub grub.org

Edit the grub file reflect these changes as shown by diff.

 diff grub.org grub
   11,12c11,12
   < GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
   < GRUB_CMDLINE_LINUX=""
   ---
   > # GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
   > GRUB_CMDLINE_LINUX="text"
   20c20
   < #GRUB_TERMINAL=console
   ---
   > GRUB_TERMINAL=console

Update grub

 sudo update-grub

Start up X

To start X in this boot session:

 service lightdm start

Service and Upstart

To Revert

Revert to X boot.

 cd /etc/default/
 sudo cp grub.orig grub
 sudo update-grub

Text Mode for Ubuntu 10.04

Reference: Modify Ubuntu for text mode

  • Edit /etc/init/rc-sysint.conf
 diff rc-sysinit.conf rc-sysinit.conf.org 
 14c14
 < env DEFAULT_RUNLEVEL=3
 ---
 > env DEFAULT_RUNLEVEL=2
  • Edit /etc/init/gdm.cong
 root@tabor:init# diff gdm.conf gdm.conf.org 
 13d12
 <           and runlevel[!3]

The result in gdm.conf should be:

 start on (filesystem
         and started dbus
         and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
              or stopped udevtrigger))
         and runlevel[!3]
 stop on runlevel [016]

Warning: Don't have an SD card connected to the USB port - maybe it tried to boot from it?

To get it going in X.

startx

nomachine

nomachine


Virtual Consoles

Virtual Consoles

  • Ctrl+Alt+F1 to F6 are the virtual consoles provided by the getty/agetty programs.
  • Ctrl+Alt+F7 is the console where your X server is running. The GUI (Gnome/KDE or any other) runs over X.

Gnome Terminal

old

Hamburger icon in up right corner

  • To use system default fonts:
    • Press the menu button in the top-right corner of the window and select Preferences.
    • Note: In the sidebar, select your current profile in the Profiles section.
    • Select Text.
    • Unselect Custom font.


new

font size

  • right clike in termina
    • preferences
      • bottom tab bottom (Terminal name)

LXTerminal

Needed for demos

 sudo apt install lxterminal

 lxterminal &

To change font size (right click in terminal)

  • Edit > Preferences > Style

Won't Boot

Boot from the 10.04 Install CD.

 sudo mkdir /media/tmp
 mount /dev/sda1 /media/tmp
 cd /media/tmp/etc                      fix things

ssh

Install

 sudo apt-get install openssh-server

Two ways to start service

 sudo /etc/init.d/ssh start
 sudo service ssh start

Two was to stop service

 sudo /etc/init.d/ssh stop
 sudo service ssh stop

Using ssh on Mac

ssh -X eepp@10.0.0.122

on Mac

system load

uptime
top
dstat
cat /proc/loadavg

/proc man

load from wikipedia

disk usage

 df

add partition formatting info

 df -Th

locate large files

 sudo find . -size +100M -ls
 
 sudo find . -size +1G -ls

change hostname

  • Edit /etc/hostname , make the name change, save the file.
  • You should also make the same changes in /etc/hosts file.
  • Run sudo /etc/init.d/hostname restart or sudo service hostname restart. (There is no hostname init script so I rebooted.)
  • change name

Printing

setting up

Ubuntu 14.x Something like:

  • Preferences -> Printers
  • Add
  • Device first expand Network Printer
  • Device choose Network Printer
  • Enter 10.0.0.3 as Host and press find

Ubuntu 18.04

  • select Activities in up left corner
  • search for Printer
  • select Printers program
  • press the green "Add" button in the upper right
  • enter the "10.0.0.3" address
  • select the "HP-LaserJet -1220"
  • choose the gutenprint driver
  • press the gear icon to the right of the "HP-LaserJet-1220" printer
  • select "Use Printer by Default"
  • Hood Ubuntu 18.04 Printer Setup 202003 Notes and Log

a2ps

Also install ascii 2 ps

 sudo apt-get install a2ps

print 1 column, landscape, line count every 5 lines, 132 char per line

 a2ps --columns=1 -r -C -l 132
 -r     --landscape
 -R     --portrait
 -l     --lines-per-page
 -c     --line-numbers=5
 -o     --output

find

 find /opt/ros/jade/ -name *.so -exec grep CamShift "{}" ";"

usb udev

Locate the devices that need permission set

 lsusb
   Bus 002 Device 009: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
   Bus 002 Device 008: ID 046d:c216 Logitech, Inc. Dual Action Gamepad
   Bus 002 Device 002: ID 046d:0805 Logitech, Inc. Webcam C300

Create the following rules file.

 cat /etc/udev/rules.d/95-floor-hugger.rules
 
   # Logitech, Inc. Webcam C300
   SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="0805", MODE="666"
 
   # Logitech, Inc. Dual Action Gamepad
   SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c216", MODE="666"
 
   # Van Ooijen Technische Informatica Teensyduino Serial
   SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="0483", MODE="666"

Hardware Info

 sudo apt-get install hardinfo
 hardinfo&

or

 lspci -nnk | grep net -A2

or

 lshw

Wireshark

 $ sudo apt-get install wireshark
 $ sudo dpkg-reconfigure wireshark-common 
 $ sudo usermod -a -G wireshark $USER
 $ sudo reboot

Logs

 dmesg
 /var/log/boot.log

apport messages

Got rid of continues report error messages.

 $ pwd
     /etc/default

 t$ diff apport.org apport
     4c4,5
     < enabled=1
     ---
     > enabled=0
     >

eog

image viewer

fromdos

Convert dos text to linus

 $ sudo apt-get install fromdos
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     E: Unable to locate package fromdos

Links

man pages