Search:

PmWiki

pmwiki.org

edit SideBar

Main / Solver

Key Shortcuts, Nifty Tricks

ctrl + alt + T = open terminal
/ = follow with search string for man pages (like vi)
Other VI shortcuts here: http://www.lagmonster.org/docs/vi.html
ctrl + alt + pageU/D = change tabs in gedit

Show only a specific amount of command history with history N for N lines/commands.

Copy entire file systems with an advanced command to preserve permissions and links properly, such as rsync -aHAX <src> <dest>

Splash screen

ctrl + alt + F5 = get prompt
ctrl + alt + F7 = get X

Colors

http://unix.stackexchange.com/questions/94498/what-causes-this-green-background-in-ls-output
https://ubuntuforums.org/showthread.php?t=41538
http://stackoverflow.com/questions/14468403/dircolors-does-not-affect-existing-files-only-new-files

Users

To allow non-logged-in users to run GUI apps on the desktop, use xhost +username@localhost or xhost +si:localuser:username.

Permissions

To change permissions on all dirs in a tree:
find . -type f -print0|xargs -0 chmod -R 774

To make all new files in a tree have the same group owner as the parent:
find . -type d -print0|xargs -0 chmod -R g+s which sets the GID for the dirs.

Disk utils

du -cs <file or folder> = disk usage (appears to be -k, size in KB, by default)
du -csm . for megabytes
fallocate creates real disk space using files

If you are trying to mount and get this error

sudo mount -t auto /dev/sda /media/sdcard
mount: you must specify the filesystem type

You probably need to use /dev/sda1.

To rescue yourself from

EXT4-fs error (device mmcblk0p2): ext4_mb_generate_buddy:736: group 43, 5655 blocks in bitmap, 5656 in gd

use sudo e2fsck -c /dev/sdd2 on the unmounted drive.

Use df to get a cleaner print than simply mount.

To see more information in a nicer view than fdisk use cfdisk.

Bash

Shortcuts: http://www.aboutlinux.info/2005/08/bash-shell-shortcuts.html

.bashrc function for setting terminal tab title on command line:

# enable title changes to terminal tabs
# function to set terminal title
function set-title(){
  if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
  fi
  TITLE="\[\e]2;$*\a\]"
  PS1=${ORIG}${TITLE}
}

.bashrc function for adding a series of named tabs to your terminal:

function term4me(){
	gnome-terminal \
	--tab-with-profile=git-tabs --working-directory=/home/ts/somedir \
-e 'bash -c "export SET_TITLE=somedirWORK; bash"' \
	--tab-with-profile=git-tabs --working-directory=/home/ts/somedir2 \
-e 'bash -c "export SET_TITLE=somedir2WORK; bash"' \
	--tab-with-profile=git-tabs --working-directory=/home/ts/somedir3 \
-e 'bash -c "export SET_TITLE=somedir3WORK; bash"'
}

Process info

Use ps auxww to show process run status

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers
(header "STAT" or "S") will display to describe the state of a process.
D    Uninterruptible sleep (usually IO)
R    Running or runnable (on run queue)
S    Interruptible sleep (waiting for an event to complete)
T    Stopped, either by a job control signal or because it is being traced.
W    paging (not valid since the 2.6.xx kernel)
X    dead (should never be seen)
Z    Defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may
be displayed:
<    high-priority (not nice to other users)
N    low-priority (nice to other users)
L    has pages locked into memory (for real-time and custom IO)
s    is a session leader
l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+    is in the foreground process group

How to find the PID for a program, knowing only it's name?
pgrep -d, <name>

How to find stack or heap size for a running program?
fgrep '[stack]' /proc/<pid>/maps

Background a Process

0. Run some command
1. ctrl+z to stop (pause) the program and get back to the shell
2. bg to run it in the background (fg brings it back)

When a process goes to the background, it essentially becomes a daemon and it's new parent becomes the init process. A fork and exit. https://stackoverflow.com/questions/35705451/is-changing-parent-process-necessary-when-daemonize-a-process

Signaling

Annoying background process that's spitting out constant data to stdout? You can at least pause it with a kill -SIGSTOP <pid>

Graphical Kernel Map

http://www.makelinux.net/kernel_map/

Breaching the infamous libstdc++5 wall

Uh oh - libstdc++.so.5: cannot open shared object file: No such file or directory
Newer versions of Ubuntu replaced libstdc++5 with v6, but some SW is not happy with that. To get it back, download the debian v5 package as needed:
libstdc++5_3.3.6-20_amd64.deb
libstdc++5_3.3.6-20_i386.deb
and then use sudo dpkg -i libstdc++5_3.3.6-20_amd64.deb
In some instances of working on a 64bit platform but using 32bit SW, you may need to force install the 32bit version by using the --force-architecture option. You can tell this is the case if you get an ELFCLASS error.

.../jre/bin/java: No such file or directory

This problem relates to not having some 32-bit libraries installed on your 64-bit system. To solve, do an apt-get install for the libs: libc6-i386 lib32gcc1 lib32z1 lib32stdc++6 ia32-libs
Haven't yet figured out how to solve this for Cygwin 32 or 64.

SSH Locale Complaints

We can also disable SSH locale environment variable forwarding to fix this error. Open the SSH client configuration file on your local computer.

sudo nano /etc/ssh/ssh_config

Find this line:

SendEnv LANG LC_*

Add a # sign at the beginning to comment it out. Save and close the file.

Big Mistakes

Do not uninstall python

pmwiki Main repository

https://www.mail-archive.com/pmwiki-users@pmichaud.com/msg09315.html

Ubuntu issues

If your sudo password is demanded on every command, it may be that your system time is messed up.

Dell Laptop Touchpad

It's quite simple to change the speed. Open up /usr/share/X11/xorg.conf.d/40-libinput.conf and make the needed edits to the touchpad entry.

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "DisableWhileTyping" "True"
        Option "AccelProfile" "adaptive"
        Option "AccelSpeed" "0.6"
        Driver "libinput"
EndSection

Dell Laptop Touchscreen

There's a lot of nonsense out there about how to disable it, but it's actually VERY simple for Ubuntu 20.

Get the name of the touch device with xinput --list. Then add a line to your /home/<user>/.profile file that says xinput disable '<devname>'.

Dell Tower Fan Control

Use i8kctl utility. You can set the fan speed manually with i8kctl fan 1 1.

tyler@Tyler-XPS-8930:~$ cat /sys/class/hwmon/hwmon2/device/hwmon/hwmon2/fan1_label 
Processor Fan
tyler@Tyler-XPS-8930:~$ cat /sys/class/hwmon/hwmon2/device/hwmon/hwmon2/fan2_label 
Motherboard Fan

When you change the fan speed, this alters the PWM values in the driver among 0/128/255:

tyler@Tyler-XPS-8930:~$ cat /sys/class/hwmon/hwmon2/subsystem/hwmon2/pwm1 
128
tyler@Tyler-XPS-8930:~$ cat /sys/class/hwmon/hwmon2/subsystem/hwmon2/pwm2 
128

https://www.google.com/search?channel=fs&client=ubuntu&q=explain+dell_smm_hwmon+ubuntu
https://docs.kernel.org/hwmon/dell-smm-hwmon.html
On many Dell laptops the System Management Mode (SMM) BIOS can be queried for the status of fans and temperature sensors. Userspace utilities like sensors can be used to return the readings. The userspace suite i8kutils can also be used to read the sensors and automatically adjust fan speed (please notice that it currently uses the deprecated /proc/i8k interface).

Dell laptop lid close actions

The settings are contained in /etc/systemd/logind.conf and /etc/UPower/UPower.conf

Login screen display manager

To stop the system from suspending itself while awaiting login, use:

sudo su
su lightdm -s /bin/bash
dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
exit
exit

notify-osd

To get rid of those annoying network pop ups, get to system monitor with gnome-system-monitor and find notify-osd and stop it. Stop it now!!

Using apt-get

If you keep running into a 404 Not Found error when trying to install new packages, someone probably deleted the files off of the archive URL that /etc/apt/sources.list points to. Try replacing each archive with old-releases in the URLs.

Behind a proxy server, you may get a 401 Unauthorized error with apt. Create a file /etc/apt/apt.conf and add the lines:

Acquire::http::proxy "http://user:pass@server.site.com:8080/";
Acquire::https::proxy "https://user:pass@server.site.com:443/";
Acquire::socks::proxy "socks://user:pass@server.site.com:1080/";

If you are messing around with Unity and end up with a black background and no changes to wallpapers are taking, try the command gsettings set org.gnome.settings-daemon.plugins.background active true.

Infamous Linux static IP loss problem

https://askubuntu.com/questions/459140/why-dhclient-is-still-running-when-i-choose-static-ip
ifdown, then edit, then ifup
https://ubuntuforums.org/showthread.php?t=1199700
https://help.ubuntu.com/community/NetworkConfigurationCommandLine/Automatic

Running a 32-bit app on a 64-bit system

The error often looks something like " No such file or directory". Had success with sudo apt-get install gcc-multilib. When you go to install all the missing 32-bit arch libraries that you'll need, make sure you have i386 as a supported arch in the /etc/apt/sources.list. See more: https://askubuntu.com/questions/454253/how-to-run-32-bit-app-in-ubuntu-64-bit

Audio device control

sudo add-apt-repository ppa:yktooo/ppa
sudo apt-get update
sudo apt-get install indicator-sound-switcher

Installs to /usr/bin/indicator-sound-switcher

Window switching

Problem is usually Unity's stupid grouping. Need to deactivate those and use the Compiz static switcher instead via https://askubuntu.com/questions/68151/unity-how-do-i-revert-alt-tab-behavior-to-switch-between-windows-on-the-current

Installing libssl-dev

It may not cleanly install, with something like this:

sudo apt install libssl-dev
The following packages have unmet dependencies:
 libssl-dev : Depends: libssl1.1 (= 1.1.1f-1ubuntu2) but 
1.1.1g-1+ubuntu18.04.1+deb.sury.org+1 is to be installed

I tried all the suggestions like sudo aptitude install libssl-dev and couldn't get anything to work. Ultimately what I had to do was download the .deb files needed from http://security.ubuntu.com/ubuntu/pool/main/o/openssl/ getting one for libssl and one for libssl-dev. Make sure the versions and platform match. Installing these manually with dpkg worked.

This confirms installation:

sudo apt-cache policy libssl-dev

libssl-dev:
  Installed: 1.1.1f-1ubuntu2.23
  Candidate: 1.1.1f-1ubuntu2.23
  Version table:
 *** 1.1.1f-1ubuntu2.23 100
        100 /var/lib/dpkg/status
     1.1.1f-1ubuntu2.22 500
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     1.1.1f-1ubuntu2.20 500
        500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
     1.1.1f-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
     1.1.0g-2ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        500 http://cz.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Note that a change in function naming between OpenSSL 1.0 and 1.1 can cause problems, see here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245419

ls column legend

file type, permissions, number of hard links, owner name, group name, size in bytes (or device major/minor numbers), timestamp

If you see a file mode octal representation (type-id-perm), here is the decoding of the type portion:

S_IFMT 0170000 bit mask for the file type bit field	
S_IFSOCK 	0140000 	socket
S_IFLNK 	0120000 	symbolic link
S_IFREG 	0100000 	regular file
S_IFBLK 	0060000 	block device
S_IFDIR 	0040000 	directory
S_IFCHR 	0020000 	character device
S_IFIFO 	0010000 	FIFO

Do a selective recursive rm

find . -name <name> -exec rm {} \;

Booting desktop from a USB stick

Had all kinds of trouble getting this to work with different disk creation tools. Finally hit on the right combo and using a Windows machine: Rufus tool (yes on disk check, no on quick format), pre-format the drive to FAT16 using diskpart, I reverted to an older Xubuntu release (14.04).

Set up hibernate ability on Ubuntu

https://blog.ivansmirnov.name/how-to-set-up-hibernate-on-ubuntu-20-04/

Basically need to expand size of swap space so that all of RAM can be saved to disk, install a couple tools and changes to the GRUB startup, and use the command sudo systemctl hibernate.

Linux News

Starting with Ubuntu 15, huge ethernet port naming convention changes. https://askubuntu.com/questions/689070/network-interface-name-changes-after-update-to-15-10-udev-changes

Mounting a network drive

Add this line to /etc/fstab

//<ipaddr>/<foldername> /mnt/<mountfoldername> auto nosuid,nodev,nofail,username=<user>,password=<pw>

#for example, note the space in the server folder name and how it's escaped
//10.2.10.44/Company\040Share /mnt/CoShare auto nosuid,nodev,nofail,username=juice,password=juicepw

Page last modified on November 18, 2024, at 04:29 PM