To add a existing user to a group
usermod -a -G thegroup theuser
To add a user to a group when the user is created
useradd -G thegroup theuserTo add a existing user to a group
usermod -a -G thegroup theuser
To add a user to a group when the user is created
useradd -G thegroup theuserUUID is a nice way to generate (almost) unique id’s.
However on PostgreSQL 8.3 the data type exists, but if you wish to be able to generate UUID’s you need to get a module (in this case uuid-ossp).
On Debian this module is in the contrib package, so if you have not installed this before do it now
user@server:~$ sudo apt-get install postgresql-contrib
Then you need to “load” the module into PostgreSQL; or more accurately you tell PostgreSQL about the new functions this module has, how to reach them etc.
Depending on you security settings (in pg_hba.conf) you may need to log in as the postgres user on your system.
postgres@sever:~$ psql -d MYDB -U postgres -f /usr/share/postgresql/8.3/contrib/uuid-ossp.sql
First off, quick explanation.
Suspend saves a image to ram. It is faster to save and reload; but the computer uses a minimal amount of energy to keep this in ram. If the power is lost (battery is drained etc) then the image is lost.
Hibernate save a image to disk. It is slightly slower to save and reload; but there is no problem if the power is lost.
However I am not the only one that have noticed that hibernate/suspend on Ubuntu does not work on a default installation.
One solution that more than me have found to be working is to switch to uswsusp.
user@laptop$ sudo apt-get install uswsusp user@laptop$ sudo s2disk
s2disk does a hibernation (s2ram does a suspend); and it is good to test it out before swapping the hibernate/suspend function.
When you know hibernate/suspend works, you can swap to using uswsusp by using:
user@laptop$ sudo dpkg-divert --rename --divert /usr/sbin/pmi-disabled /usr/sbin/pmi
If you later on would like to swap back you can use
user@laptop$ sudo dpkg-divert --rename --remove /usr/sbin/pmi
On *nix environments it is possible to forward the mail to one account to another user (or another email address if external mail is supported).
This is done by adding the recipient in a file called .forward in the home directory.
Example To simply forward to another address:
user@server$ echo recipient@mail.com > ~/.forward user@server$ chmod go-w ~/.forward
In order to forward to several addresses coma (,) is used as a delimiter between the different recipients.
Example To forward to two addresses at the same time:
user@server$ echo recipient1@mail.com,recipient2@mail.com > ~/.forward user@server$ chmod go-w ~/.forward
If you try to use sudo to get to a directory (for instance if the user calling sudo don’t have permissions for that folder) then you will see an error message like this
user@server:~$ sudo cd /var/log/ sudo: cd: command not found
While I don’t know how to get sudo to work with cd I can offer some workarounds.
As far as I can tell the problem with sudo cd is that if it would have worked the user would be in a directory that he/she has no permissions to so nothing is gained and having a folder that the user don’t have permissions to as the working directory might cause problems in more way than one.
sudo ls /var/log sudo cat /var/log/syslog
sudo -s
this will give you a shell with su permissions
sudo -i
this will also give you su permissions but with the difference that it will be like logging in like root (home dir, profile, variables etc) [this would be equivalent of running "sudo su"]
sudo sh -c 'cd /var/spool/exim4/;ls'
(don’t miss the single quotes in the command)
To give some more details on the difference between -i and -s here is a excerpt from the man pages
-i [command]
The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of the target user as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed. sudo attempts to change to that user’s home directory before running the shell. It also initializes the environment, leaving DISPLAY and TERM unchanged, setting HOME, SHELL, USER, LOGNAME, and PATH, as well as the contents of /etc/environment on Linux and AIX systems. All other environment variables are removed.
-s [command]
The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd(5). If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed.
Sometimes it is nice to send a log or some other file as a email to someone (or a part of a file)
cat myfile.txt | mail -s 'SUBJECT' example@mail.com;
Change myfile.txt, SUBJECT and example@mail.com to something useful.
It is also possible to send the output of a command to someone
ps -ef|mail -s 'SUBJET' example@mail.com;
Finding the serial number of a hard drive on a Linux console (as root) is simple with the right tool.
The right tool in this case is hdparm (using the -i option).
-i will query the device directly for the details.
Example:
themachine:/proc# hdparm -i /dev/sda /dev/sda: Model=ST31500341AS , FwRev=CC1H , SerialNo= 9VS21ZXM Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4 BuffType=unknown, BuffSize=0kB, MaxMultSect=16, MultSect=?16? CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=18446744072344861488 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 AdvancedPM=no WriteCache=enabled Drive conforms to: unknown: ATA/ATAPI-4,5,6,7 * signifies the current active mode
Using the option -I instead gives even more information:
themachine:/proc# hdparm -I /dev/sda /dev/sda: ATA device, with non-removable media Model Number: ST31500341AS Serial Number: 9VS21ZXM Firmware Revision: CC1H Transport: Serial Standards: Used: unknown (minor revision code 0x0029) Supported: 8 7 6 5 Likely used: 8 Configuration: Logical max current cylinders 16383 16383 heads 16 16 sectors/track 63 63 -- CHS current addressable sectors: 16514064 LBA user addressable sectors: 268435455 LBA48 user addressable sectors: 2930277168 device size with M = 1024*1024: 1430799 MBytes device size with M = 1000*1000: 1500301 MBytes (1500 GB) Capabilities: LBA, IORDY(can be disabled) Queue depth: 32 Standby timer values: spec'd by Standard, no device specific minimum R/W multiple sector transfer: Max = 16 Current = ? Recommended acoustic management value: 254, current value: 0 DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 Cycle time: min=120ns recommended=120ns PIO: pio0 pio1 pio2 pio3 pio4 Cycle time: no flow control=120ns IORDY flow control=120ns Commands/features: Enabled Supported: * SMART feature set Security Mode feature set * Power Management feature set * Write cache * Look-ahead * Host Protected Area feature set * WRITE_BUFFER command * READ_BUFFER command * DOWNLOAD_MICROCODE SET_MAX security extension * Automatic Acoustic Management feature set * 48-bit Address feature set * Device Configuration Overlay feature set * Mandatory FLUSH_CACHE * FLUSH_CACHE_EXT * SMART error logging * SMART self-test * General Purpose Logging feature set * WRITE_{DMA|MULTIPLE}_FUA_EXT * 64-bit World wide name Write-Read-Verify feature set * WRITE_UNCORRECTABLE_EXT command * {READ,WRITE}_DMA_EXT_GPL commands * Segmented DOWNLOAD_MICROCODE * SATA-I signaling speed (1.5Gb/s) * SATA-II signaling speed (3.0Gb/s) * Native Command Queueing (NCQ) * Phy event counters Device-initiated interface power management * Software settings preservation * SMART Command Transport (SCT) feature set * SCT Long Sector Access (AC1) * SCT LBA Segment Access (AC2) * SCT Error Recovery Control (AC3) * SCT Features Control (AC4) * SCT Data Tables (AC5) unknown 206[12] (vendor specific) Security: Master password revision code = 65534 supported not enabled not locked not frozen not expired: security count supported: enhanced erase 240min for SECURITY ERASE UNIT. 240min for ENHANCED SECURITY ERASE UNIT. Logical Unit WWN Device Identifier: 5000c50014ec1f60 NAA : 5 IEEE OUI : c50 Unique ID : 014ec1f60 Checksum: correct
To mark a message as unread in pine this can be done using flags.
First flags have to be turned on in setup
[M]ain [S]etup [C]onfig
Then find “enable-flag-cmd” and turn it on.
After this marking a message as unread is done by “* N” in the list view or when looking at the message.
All the flags are:
[^T] Can be used to see all the flags and set/unset them one by one (or all).
apt-get is verifying the packages before installing them.
If the keys are not up to date, then apt-get upgrade will issue a warning.
WARNING: The following packages cannot be authenticated! ure uno-libs3 Install these packages without verification [y/N]?
The way to solve this is rather simple, just run apt-get update and it should download the keys automatically.
apt-key handles keys, using apt-key list will show you the keys that are on the computer.
Sometimes it is nice to limit the download speed of apt-get.
The way I do this is to create a file “/etc/apt/apt.conf.d/76download” and enter the following to it
Acquire{Queue-mode "access";http{Dl-Limit "50";};};
This will limit apt-get to at most 50 kb/s for apt-get.
Some other how to’s suggest the use of dl-limit but be adviced, dl-limit is per each connection apt-get does (normally it does 2 at a time); the one used above caps apt-get in total.