Setting audio volume from CLI:
With pactl:
Rise volume 10% up:
pactl set-sink-volume 0 +10%
Lower volume 10% down:
pactl set-sink-volume 0 -10%
Set volume at 50%:
pactl set-sink-volume 0 50%
Be careful! pactl/pacmd allows volume over 100% !:
pactl set-sink-volume 0 150%
What is “dist-upgrade” and why does it upgrade more than “upgrade”?
After doing sudo aptitude update && aptitude upgrade ...
A message like this shows:
E: Can not find source for linux-image-xxxx, linux-image-xxxx
To fix this error, go to console and type:
ssudo apt-get update <--- to update the source list database
sudo apt-get upgrade <--- to upgrade the existing packages
sudo apt-get dist-upgrade <--- to upgrade SOLVING conflicts and/or dependencies (will REMOVE existing software if it is necessary!)
So ... apt-get dist-upgrade should fix it!
Error after Virtualbox update (VBox: Kernel driver not installed (rc=-1908))
After updating Virtualbox and running:
/etc/init.d/vboxdrv setup
This error message apears: Kernel driver not installed (rc=-1908)
To fix this error, go to console and type:
sudo apt-get install linux-headers-$(uname -r)
sudo apt-get remove virtualbox-dkms
sudo apt-get install virtualbox-dkms
This should fix it!
or ...
Add one of the following lines according to your distribution to your /etc/apt/sources.list:
deb http://download.virtualbox.org/virtualbox/debian trusty contrib deb http://download.virtualbox.org/virtualbox/debian saucy contrib deb http://download.virtualbox.org/virtualbox/debian raring contrib deb http://download.virtualbox.org/virtualbox/debian quantal contrib deb http://download.virtualbox.org/virtualbox/debian precise contrib deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free deb http://download.virtualbox.org/virtualbox/debian wheezy contrib deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
For example, to add the repository for Ubuntu 12.04 Precise Pangoline, at CLI type:
sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian precise contrib" >> /etc/apt/sources.list.d/virtualbox.list'
(Up to version 3.2 the packages were located in the non-free section. Starting with version 4.0 they are located in the contrib section.)
The Oracle public key for apt-secure can be downloaded here. You can add this key with
sudo apt-key add oracle_vbox.asc
or combine downloading and registering:
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
The key fingerprint is
7B0F AB3A 13B9 0743 5925 D9C9 5442 2A4B 98AB 5139 Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
(As of VirtualBox 3.2, the signing key was changed. The old Sun public key for apt-secure can be downloaded here.)
To install VirtualBox, do
sudo apt-get update sudo apt-get install virtualbox-4.3
Replace virtualbox-4.3 by
virtualbox-4.2 to install VirtualBox 4.2.18
virtualbox-4.1 to install VirtualBox 4.1.28
virtualbox-4.0 to install VirtualBox 4.0.20
virtualbox-3.2 to install VirtualBox 3.2.22
Note: Ubuntu/Debian users might want to install the dkms package to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade. For Debian it is available in Lenny backports and in the normal repository for Squeeze and later. The dkms package can be installed through the Synaptic Package manager or through the following command:
sudo apt-get install dkms
What to do when experiencing The following signatures were invalid: BADSIG ... when refreshing the packages from the repository?
# sudo -s -H # apt-get clean # rm /var/lib/apt/lists/* # rm /var/lib/apt/lists/partial/* # apt-get clean # apt-get update
"A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children.
A program that is run in such a modified environment cannot name (and therefore normally not access) files outside the designated directory tree."
AND with it you could do things like...
A Custom Live CD ( Based on Ubuntu Precise pangolin 12.04 LTS Live CD image using chroot. :)
(Posted on http://ubuntuforums.org by joshuariley on May 2nd, 2013)
LiveCdRecovery (Ubuntu Official Documentation)
OR
What's the proper way to prepare chroot to recover a broken Linux installation?
Wich includes things like...
Change a Lost Administrative Password (Booting in Single User Mode)
Recover a forgotten root password on Redhat 7 Linux Selinux system
Contents
1. Edit GRUB2 boot menu
2. Read&Write root partition remount
3. Change root's password
4. SELinux relabeling
5. Reboot System
The way on how you can reset a forgotten root password on a Linux system have not changed for many years. Resetting a root password on RHEL7 Linux system have not change much except that now we deal with SElinux and the system is now using systemd instead of init. Nevertheless, those who have already did reset root password on the Linux system will be with the following steps familiar. Here is the procedure of what needs to be done in order to recover a forgotten root password on Redhat 7 Linux:
We need to edit GRUB2 boot menu and enter user single mode
Next, we need to remount / partition to allow read and write
Reset the actual root password
Set entire system for SElinux relabeling after first reboot
Reboot the system from a single mode
Now that we understand the procedure we can proceed with Redhat 7 password recovery.
Edit GRUB2 boot menu
Start your system and once you see your GRUB2 boot menu use e key to edit your default boot item.
Usually it is the first line:
Edit boot menu to initiate RHEL7 root password recovery
Editing RHEL7 boot menu to enter single mode
Locate a line with rhgb quiet keywords:
Move your cursor ( HINT: move to end of the line with CTRL+E ) on rhgb quiet keywords and replace them with init=/bin/bash as show below:
Once you edit the boot line as show above press CTRL + x to start booting your RHEL 7 system into a single mode.
At the end of the system boot you will enter a single mode:
Read&Write root partition remount
Once you enter a single your root partition is mounted as Read Only ro. You ca confirm it with the following linux command:
# mount | grep root
In order to mount our partition with Read/Write flag we use mount with a remount option as follows:
# mount -o remount,rw /
Next, confirm that the root file system is mounted Read/Write rw:
# mount | grep root
All the above steps are show below:
Remount root filesystem as read&write on redhat 7 Linux server
Change root's password
Still in the single mode we can proceed with the actual root password recovery. To do this we use passwd command:
# passwd
You will need to enter your password twice as shown below:
Recover a forgotten root password on RHEL7 linux server
SELinux relabeling
The additional step which needs to be taken on SELinux enables Linux system is to relabel SELinux context. If this step is ommited you will not be able to login with your new root password. The following linux command will ensure that the SELinux context for entire system is relabeled after reboot:
# touch /.autorelabel
SELinux relabel system after reboot - Redhat 7 Server
Reboot System
The final step when resetting your lost root password on RHEL 7 linux system is to reboot.
This can be done with a following linux command:
# exec /sbin/init
After reboot you will be able to use your new root password.
Please note that you can usually boot into RecoveryMode and run the passwd command directly.
Boot the Ubuntu Live CD.
Press Ctrl-Alt-F1
sudo mount /dev/sda1 /mnt
If you created a custom partition layout when installing Ubuntu you have to find your root partition using the fdisk utility.
See the section Finding your root partition
sudo chroot /mnt
You can now use the passwd command to reset a password.
After the message:
passwd: password updated successfully
Type:
exit
and unmount your partition
umount /mnt
and poweroff or reboot the system
reboot
Note: In the mount command, /dev/sda1 will need to be replaced with the partition where the root of the file system resides.
Add User to a Group
If you have removed yourself from a group, you can use the following to add yourself again.
Please note that you can usually use RecoveryMode and run the adduser command directly.
Boot the Ubuntu Live CD.
Press Ctrl-Alt-F1
sudo mount /dev/sda1 /mnt
sudo chroot /mnt
adduser username groupname
Fix Update Failures
If there was an update that made your system non-bootable and they have fixed it in the repositories, you can use the Live CD to run apt-get to get the new files to fix your system.
Boot the Ubuntu Live CD.
Press Ctrl-Alt-F1
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount -o bind /dev/pts dev/pts/
sudo mount -o bind /run run/
cp -v /etc/resolv.conf etc/resolv.conf
swapon /dev/sdxY # Swap enabled, if needed
source /etc/profile
source ~/.bashrc
export PS1="(chroot) $PS1" # add a reminder to your prompt
sudo chroot /mnt # OR: sudo chroot /mnt /bin/bash
Note: If you see the error:
chroot: cannot run command '/usr/bin/bash': Exec format error
it is likely that the architectures of the host environment and chroot environment do not match.
chroot: '/usr/bin/bash': permission denied
remount with the exec permission:
mount -o remount,exec /mnt
apt-get update
apt-get upgrade
After you make the necesary system changes do:
exit
cd /
umount --recursive /location/of/new/root
If you have trouble accessing your network after chroot, you probably use DHCP and can work around this by adding OpenDNS name servers to your /etc/resolv.conf after you use chroot:
nameserver 208.67.222.222
nameserver 208.67.220.220
If you created a custom partition layout during the Ubuntu installation, your root partition is probably not /dev/sda1 or /dev/sda1. If you do not know which partition corresponds to your root partition you can use the following procedure to find your root partition. We assume you have booted the live cd and are at the terminal.
If you are not using a software raid setup or have setup your partitions using LVM/2 or EVMS your IDE/SATA/SCSI devices should be accessible through the files /dev/hd[a-z] and /dev/sd[a-z]. /dev/hda corresponds to the primary master device on your IDE bus, while /dev/sda is your first SCSI/SATA device. If you are using software raid, LVM, LVM2 or EVMS, your devices may be listed in the following directories:
/dev/evms/dm if you are using software raid /dev/evms/lvm if you are using LVM /dev/evms/lvm2 if you are using LVM2 /dev/evms if you are using EVMS
with their device (software raid) or partition name. You can learn more about Linux partitions here: http://tldp.org/HOWTO/Partition
Now use the fdisk utility to list the partitions on a device. Let's assume that you installed Ubuntu to the fist IDE disk. Type the following:
sudo fdisk -l /dev/sda
This will produce some output like this:
Password:Disk /dev/sda: 120.0 GB, 120034123776 bytes 16 heads, 63 sectors/track, 232581 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13206 6655792+ 7 HPFS/NTFS /dev/sda2 13207 232581 110565000 5 Extended /dev/sda5 228706 232484 1904616 82 Linux swap / Solaris /dev/sda6 13207 228705 108611464+ 83 Linux /dev/sda7 232485 232581 48856+ 83 Linux Partition table entries are not in disk order
That means you have two standard Linux partitions on your disk: /dev/sda6 and /dev/sda7. You can now try to mount them and see if your Ubuntu installation is there. In this case /dev/sda7 is probably not the root partition, because it is only about 50MiB in size (see the Blocks column). Therefore we mount /dev/sda6:
sudo mount /dev/sda6 /mnt
Now show the files on the partition:
ls /mnt
If this command shows something like:
bin dev home media proc sbin tmp var boot etc lib opt root sys usr
it is a partition holding a Linux distribution. You can check if it really is Ubuntu (if you have multiple linux installations on your disk) using the following command:
cat /mnt/etc/lsb-release
That will give you some information about the distribution (if this file does not exist, it is probably not Ubuntu). If it is the wrong partition, just unmount it: sudo umount /mnt and try another partition on the same disk or choose a different partition on another disk (using fdisk as before).
Recover Grub
If you install some other system, or change drives and lose your Grub bootloader.
For more information please have a look at the Grub page.
Boot the Ubuntu Live CD.
Press Ctrl-Alt-F1
Find the partition where your /boot directory is (normally the root partition) check the previous tip for that.
sudo mount /dev/sda1 /mnt
sudo chroot /mntgrub
find /boot/grub/stage1
(will output a partition name like (hd0,3))
root (hd0,3)
setup (hd0)
quit
Now restart the system and remove the Live CD
The GUI Way: Reinstalling GrubBoot your computer with the Ubuntu CD
Go through the installation process until you reach "[!!!] Disk Partition"
Select Manual Partition
Mount your appropriate linux partions:
/
/boot
swap
... DO NOT FORMAT THEM.
Finish the manual partition
Say "Yes" when it asks you to save the changes
It will give you errors saying that "the system couldn't install ....." after that
Ignore them, keep select "continue" until you get back to the Ubuntu installation menu
Jump to "Install Grub ...."
Once it is finished, just restart your computer
From: http://doc.gwos.org/index.php/Restore_Grub and http://ubuntuforums.org/showthread.php?t=76652
Install 'simplescreenrecorder' and optionally 'simplescreenrecorder-lib:i386' (if you want to record 32-bit OpenGL applications on a 64-bit system) from the SimpleScreenRecorder PPA:
sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder
sudo apt-get update
sudo apt-get install simplescreenrecorder
# if you want to record 32-bit OpenGL applications on a 64-bit system:
sudo apt-get install simplescreenrecorder-lib:i386
You should copy-paste these commands to a terminal line by line rather than all at once, otherwise it won't work.
Change the computer/hostname without a system restart
Edit the files /etc/hosts and /etc/hostname, changing the actual Host/Computer name to the one you wish:
vi /etc/hosts
127.0.0.1 localhost
127.0.1.1 computer-or-host-name
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
vi /etc/hostname
computer-or-host-name
After the changes, save the files and execute the next command to apply the new name without a system restart:
/etc/init.d/hostname restart
Disable guest account in Ubunt and Lubuntu
For Ubuntu you can edit the file /etc/lightdm/lightdm.conf
For Lubuntu you can edit the file /etc/lightdm/lightdm.conf.d/20-lubuntu.conf
Append the line below (to the end of the file)
allow-guest=false
Restart the lightdm service (or the computer!)
sudo service lightdm restart
Note: All your running GUI applications will closed!
Disable / Manual / Enable / Services in Ubunt
You can see a demo video on YouTube showing how to enable and disable services from startup in Ubuntu 14.04
This example is for mysql service.
1) Disable startup. create a file to override the default configurations
echo manual | sudo tee /etc/init/mysql.override
2) Enable startup. remove the previous override file
sudo rm /etc/init/mysql.override
Now after a reboot, to run mysql service you must do it manualy:
sudo service mysql start
To stop mysql service manualy:
sudo service mysql stop
Dumb script to monitor update process on a remote system
You can edit this file and put it anywhere in your system
(but preferabily place it at /usr/sbin/Monitor
MonitorUpdate
clear && echo " " && w && echo " " && ps aux | grep -i apt && echo " " && ls -hails /target/boot/ && echo " "
Cada línea de comando explicada:
clear # Limpia el terminal
echo " " # Imprime un espacio horizontal en blanco
w # Muestra quien está logeado y lo que ejecuta en el sistema
ps aux # Lista los procesos que están ejecutandose en formato detallado
| grep -i apt # Busca entre los procesos los que comiencen con "apt"
ls -hails /target/boot/ # Lista los archivos en el directorio /target/boot/ con la intención de ver si directorio
Muestra direcciones IP de las tarjetas de red inalámbricas
Tarjetas Gráficas
lspci lspci | grep -i vga xrandr | grep '*' xrandr
Cada línea de comando
Lista tarjetas de vídeo
Muestra resolución y frecuencia en uso
Muestra resoluciones y frecuencias soportadas
Sonido
cat /proc/asound/cardX/codec#Y | grep Codec
lspci -vvvnnn | grep Audio
amixer
Cada línea
Imprime el códec de audio en pantalla
X y Y se reemplazan según el número de tarjeta y de códec respectivamente
Imprime el dispositivo de audio en pantalla.
Imprime información acerca de los controles presentes en el mezclador de la tarjeta de audio
Windows - Ubuntu y como grub la maneja
fdisk -list
Comandos a ejecutar antes de preguntar en foros
You can edit the file /etc/lightdm/lightdm.conf
Conexiones de red
lspci lspci | grep -i ethernet lspci | grep -i network lsusb lsusb | grep -i ethernet lsusb | grep -i network lsmod | grep iwl ifconfig iwconfig
Cada línea de comando
Lista dispositivos de red ethernet PCI
Lista dispositivos de red inalámbricos PCI
Lista dispositivos de red ethernet USB
Lista dispositivos de red inalámbricos USB
Muestra módulos inalámbricos cargados en el sistema
Muestra direcciones IP de las tarjetas de red ethernet
Muestra direcciones IP de las tarjetas de red inalámbricas
Tarjetas Gráficas
lspci lspci | grep -i vga xrandr | grep '*' xrandr
Cada línea de comando
Lista tarjetas de vídeo
Muestra resolución y frecuencia en uso
Muestra resoluciones y frecuencias soportadas
Sonido
cat /proc/asound/cardX/codec#Y | grep Codec
lspci -vvvnnn | grep Audio
amixer
Cada línea
Imprime el códec de audio en pantalla
X y Y se reemplazan según el número de tarjeta y de códec respectivamente
Imprime el dispositivo de audio en pantalla.
Imprime información acerca de los controles presentes en el mezclador de la tarjeta de audio
Windows - Ubuntu y como grub la maneja
fdisk -list
How do I get current keyboard layout with CLI in Ubunt, Lubunt, etc...
You can use this command
setxkbd -query
It will show smething like this:
rules: evdev
model: pc105
layout: us
variant: intl
options: lv3:ralt_alt,terminate:ctrl_alt_bksp
Permanently change keyboard layout with CLI in Ubunt
You can change keyboard from CLI doing something like:
sudo dpkg-reconfigure keyboard-configuration
Then choose your desired keyboard settings
In a server, try the following command:
sudo dpkg-reconfigure console-data
If you don't have the package, install console-data with:
sudo apt-get install console-data
Set Time, Date Timezone in Linux from Command Line or Gnome | Use ntp Written by Guillermo Garron Set date from the command line date +%Y%m%d -s "20120418" Set time from the command line date +%T -s "11:14:00" Set time and date from the command line date -s "19 APR 2012 11:14:00"
OR
date -s 201204191114
For 11 Jun 2019 9:30 AM
date -s 201902060930For 12 Jun 2019 1:45 PMdate -s 201906121645
Linux check date from command line date Will show you something like this: Thu Apr 19 15:17:34 BOT 2012 Set hardware clock The hardware clock is the clock that runs in you PC hardware even if you disconnect it from the main power supply. This is because it has a lithium battery in the modern computers and another type of battery in the old ones. We'll see differences between hardware clock and system clock hwclock --show Will output something like this: Thu 19 Apr 2012 03:23:05 PM BOT -0.785086 seconds Now check the system clock date Will output something like this: Thu Apr 19 15:26:41 BOT 2012 Let's set the hardware clock to local time: hwclock --set --date="2012-04-19 16:45:05" --localtime If you want to set it to UTC time use: hwclock --set --date="2011-04-19 20:45:05" --utc Set the timezone To set the timezone of your system clock do the following: cp /usr/share/zoneinfo/America/La_Paz /etc/localtime Choose the right timezone for you. Automatically adjust your computer clock To have your system to automatically adjust time we need to install ntp. Get it from your repository. Once installed you can configure it this way: Edit the file /etc/ntpd.conf. It will look like this: # With the default settings below, ntpd will only synchronize your clock. # # For details, see: # - the ntp.conf man page # - http://support.ntp.org/bin/view/Support/GettingStarted # - https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon # Associate to public NTP pool servers; see http://www.pool.ntp.org/ server 0.pool.ntp.org server 1.pool.ntp.org server 2.pool.ntp.org # Only allow read-only access from localhost restrict default noquery nopeer restrict 127.0.0.1 restrict ::1 # Location of drift and log files driftfile /var/lib/ntp/ntp.drift logfile /var/log/ntp.log # NOTE: If you run dhcpcd and have lines like 'restrict' and 'fudge' appearing # here, be sure to add '-Y -N' to the dhcpcd_ethX variables in /etc/conf.d/net Be sure to start the daemon, and to make it start automatically when the system boots. On Arch Linux is: /etc/rc.d/ntpd start on Debian and derivatives /etc/init.d/ntpd start Update from the command line against a time server You can update the clock manually, without the need of the daemon with ntpdate ntpdate 129.6.15.28 You will get something like this: 19 Apr 15:45:23 ntpdate[10948]: step time server 129.6.15.28 offset -45.697084 sec