Howto: Ubuntu Live CD root password for default user Ubuntu

sudo passwd ubuntu

Then create your password, you will need to already be in Terminal 😉

Ubuntu user: You will have to sudo once you login to do anything powerful

ubuntu default root password:

To create a usable root user’s account on a live cd, you can set the root password then su. This has not been possible in previous versions of Ubuntu as their user model made you remember to sudo before each command requiring root access.

sudo passwd root

It’s easier just to sudo command for one time use, instead of creating a root user to su to.

As of Ubuntu 9.10, I haven’t been able to login with “demo” or “Ubuntu” as the password for live session username “Ubuntu”.

If you are running most other types of linux like Debian, Red Hat, Mepis, Suse and others, they have an actual root user with an account.

It is easier to gain root access permanently, for these other flavors of Linux click here to learn how.

If you’ve forgot your root password and need to reset it, Make Magazine has a nice writeup here:

HOWTO – reset a lost Ubuntu password

My Linux Tips

To see if you’re running Nvidia or ATI Radeon drivers in Linux:
glxgears -printfps to see framerate (Mepis 6.5)

To edit or change xorg.conf, your video card and video driver settings in linux:

Drop to CTRL-ALT-F1 if you have to.
First I backup /etc/X11/xorg.conf to xorg-backup.conf then edit the file to usually drop to a lower resolution which is the one listed for 24 bit depth.
If you really cannot deal with that, you can take your chances with the tool:
sudo dpkg-reconfigure xserver-xorg

Dialup not working with KDE, (Mepis) using kpppd?
If your prompt says “The pppd daemon died unexpectedly!”

I solved it by going to /etc/ppp/peers/kppp options.txt and replacing #noauth with noauth (ie Delete the #) and all is now good. Hope this helps others

If you still cannot connect, you can try these:
1) open etc/ppp/peers/kppp-options and remove the # in front
of noauth if it is there.
2) open etc/ppp/pap-secrets and make sure your isp username
and password are there, again with no # in front of the line.
3) open etc/ppp/peers/provider and first make sure the correct
modem is listed, mine is on com port 2 so my line reads
/dev/ttyS1. Then this is the biggie because this line was very
wrong on mine. The chat script line should read :
connect “/usr/sbin/chat -v -f /etc/ppp/peers/provider”
That should do it.
By the way when putting settings in kppp (click configure button)
i used PAP and CR/LF and CRTSCTS and 115200 and /dev/ttyS1(which in
my case is com port 2).

Also do not use lock and if you really have to, change everything logged in as root.

Linux Command Line – quick list

Linux Commands and examples – short list:
ls – list contents of a directory sudo – “substitute user” (grants administrator rights)

  • ex: ls -al – list all files with size and owner and group

sudo -i – login as superuser or admin or root
cd – change directory
clear – clear screen
chmod – change file access permissions
chown – change file and group ownership

  • ex: chown -v -R googlethem:googlethem *.* (changes owner and group of ALL files in current directory, not other directories, recursively and gives verbose output). note: Recursive chown-> use * instead of *.* to chown all files inside all directories truly recursive!
    cp – copy

du -h – size of directory, h for human readable kbytes
grep – search (used as a pipe most often)

  • ex: cat example.php | grep -i cookie

ifconfig – shows IP address and other info about all interfaces including ethernet and wireless (may need /sbin/ifconfig if you are not logged in as root)
mv – move
rm – remove
cat – concatenate files (dump to screen)

  • ex: cat example.php | grep -i cookie

free -m – show free memory. A more detailed command:

  • ex: cat /proc/meminfo

nano – basic text editor – my favorite linux text editor with menus and keyboard command reference while editing
vi – advanced text editor -difficult to use because it doesn’t have a standard keyboard command set or a menu
fdisk – partition table manipulator (fdisk for windows and linux are different, their commands are unique to each platform!)

  • ex: fdisk -l (list all drives)

df – disk free (remaining / used disk space) (df reports space used)
users – users currently logged in
useradd – add a user
usermod – modify existing user
uname – show kernel version, processor type, number of cores, system data (try uname -a)
mount – mount a file system, cd or removable drive
netstat -tpe (-t show only TCP connections, -p show PID/name, -e extra info)
nslookup domainname – Show DNS server IP and website IP (I leave off the @nameserver part)
dig domainname @nameserver – Show nameserver’s A record IP and TTL (time to live)
umount – un-mount a file system, cd or removable drive
top – show current running processes updates on the fly in the command window!
touch – create new, empty, file
reboot – reboot your system
shutdown – shutdown your system
passwd – change user password
ping – ping a network device or location

  • ex: ping google.com

nslookup: googlethem.com  – Show a website’s IP address.

  • ex: nslookup: googlethem.com ns1.speedydns.net – Show IP for a domain name by looking at a specific DNS server.

more – show output one screen at a time
exit – logout of the terminal
eject – eject a cdrom or removable device
tar cvzf foo.tgz cps100 will tar the directory cps100 (and its files/subdirectories) into a tar file named foo.tgz.

  • ex: To tar all .cc and .h files into a tar file named foo.tgz use:
    tar cvzf foo.tgz *.cc *.h

find . -iname ‘filetofind.htm’

  • ex: In Linux to create a playlist with all the *.mp3, *.wav, *.ogg and *.wma in the current folder (and all subfolders) use the command:
  • find . -iname ‘*’ -print | sed -n -E -e ‘s/.*mp3/&/p’ -e ‘s/.*wav/&/p’ -e ‘s/.*ogg/&/p’ -e ‘s/.*wma/&/p’ > playlist.m3u
  • or this one:
  • find . -iregex ‘.*.(mp3|wav|ogg|wma)’ -print > playlist.m3u

find / -size +10000k -print0 | xargs -0 ls -l  To find all files larger than 20Megs on a linux server.

find . -type f -size +50000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’
To find all files larger than 50 Megs on a lunix server.

Linux Backup MBR – Master Boot Record

Backup and Restore Hard drive partitions and MBR.

This does the partition map only, not the actual partition data. To do entire drives or partitions use dd to backup and restore entire hard drives or clone drive.

* To backup use:
sudo dd if=/dev/hda of=mbr.backup bs=512 count=1
* To restore use:
sudo dd of=/dev/hda if=mbr.backup bs=512 count=1

Caution the MBR contains the partition table (the first four primary entries) it will break things if you changed the partition since the backup.

If you do not want to restore the partition table you should use sudo dd of=/dev/hda if=mbr.backup bs=446 count=1 instead. This will write only the first 446 bytes of the MBR leaving the last 64 bytes intact (4 partition table entries * 16 bytes/entry). You can restore an MBR even from a backup that has all 512 bytes just by specifying 446 on the restore operation!

Be warned that you may not be able to boot from this disk if you changed the partition table after the backup of the MBR, depending on the actual boot loader .

Click here If you want to linux disk backup dd.

Formatting a USB thumbdrive back to original using Linux fdisk command line

If you like Linux command line tools, fdisk is a good one for partitioning and formatting USB memory sticks, aks thumbdrives. This works for windows formatted thumbdrives as well.

WARNING: This process will delete any information that is currently stored on the USB key. Proceed with caution! When you Fdisk thumb drive you are likely to delete the entire USB thumb drive. You are in effect “formatting usb memory sticks”.

Reverting your USB key back to it’s original state:

A.) First we need to delete the old partitions that remain on the USB key.

1. Open a terminal and type sudo su
2. Type fdisk -l and note your USB drive letter.
3. Type fdisk /dev/sdX (replacing X with your drive letter)
4. Type d to proceed to delete a partition
5. Type 1 to select the 1st partition and press enter
6. Type d to proceed to delete another partition (fdisk should automatically select the second partition)

B.) Next we need to create the new partition.

1. Type n to make a new partition
2. Type p to make this partition primary and press enter
3. Type 1 to make this the first partition and then press enter
4. Press enter to accept the default first cylinder
5. Press enter again to accept the default last cylinder
6. Type w to write the new partition information to the USB key
7. Type umount /dev/sdX (replacing X with your drive letter)

C.) Lastly we need to create the fat filesystem.
For FAT16!
1. Type mkfs.vfat -F 16 /dev/sdX1 (replacing X with your USB key drive letter)

That’s it, you should now have a restored USB thumb drive with a single fat 16 partition that can be read from any computer.

Linux backup entire disk drive image to a file or another drive with dd command

You can:

Clone from one hard drive to another of different size:
Backup a drive to another drive dd
Use dd command to image
Backup drive using linux
Linux dd backup drive or Linux disk image dd

This works with Windows 7, Mac OS X, Vista and any Linux.

Note: If you just want to backup or restore your partition table and or the MBR click here.

From Linux Questions Wiki:

Creating a hard drive backup directly to another hard drive, or linux backup entire disk.

# dd if=/dev/hda of=/dev/sda conv=noerror,sync bs=4k

This command is used often to create a backup of a drive (/dev/hda) directly to another hard drive (/dev/sda). The device name /dev/hda is typical of an IDE hard drive, the device /dev/sda is typical of a USB disk – key drive. This works only if the destination hard drive (of=) has enough storage to accommodate the source drive’s (if=) filesystem. The advantage of this is that you do not have to mount the hard drive to make a backup and the only reference to hda is in /dev and in the command which is usually in a script in cron. Another huge advantage of using dd to clone one hard drive to another is that this is the only way I know of that copies raw data instead of partitions, so you can clone an encrypted drive or one without partitions.

The option “bs=4k” is used to specify the block size used in the copy. The default for the dd command is 512 bytes: use of this small block size can result in significantly slower copying. However, the tradeoff with larger block sizes is that when an error is encountered, the remainder of the block is filled with zero-bytes. So if you increase your block size when copying a failing device, you’ll lose more data but also spend less time trying to read broken sectors. Tools like dd_rescue and dd_rhelp can provide a more flexible solution in such cases, combining the speed of a large block size for the regions without errors with finer-grained block-copies for regions with errors.

Creating a hard drive backup image or dd command image backup linux.

# dd if=/dev/hda | gzip > /mnt/hdb1/system_drive_backup.img.gz

Here dd is making an image of the first harddrive, and piping it through the gzip compression program. The compressed image is then placed in a file on a seperate drive. To reverse the process:

# gzip -dc /mnt/hdb1/system_drive_backup.img.gz | dd of=/dev/hda

Here, gzip is decompressing (the -d switch) the file, sending the results to stdout (the -c switch), which are piped to dd, and then written to /dev/hda.

To backup or copy a cd to a file with linux using dd is very easy:

dd if=/dev/cdrom of=image.iso bs=2k.

Samba server syncing files – Problem copying files from Windows to Linux, especially in Mepis

Problem: When file names with international character sets copy from Windows to Linux in Mepis the characters are not translated properly.

Detail: When your files copy from Windows to Linux and the international characters (like African and Brazilian song names) don’t copy correctly, all other filenames are fine, you need to edit your /etc/samba/smb.conf file which is the config file for samba.

Solution: Put this in to the head of the file to fix odd international characters from windows to linux copy:

unix charset = ISO 8859-1

Remember to stop and restart your Samba server: (Linux Mepis and Ubuntu) sudo /etc/init.d/samba restart

Problem: When your use a program to synchronize files from Windows to Linux (Mepis) and some files continually recopy even though they are the same (identical dates) on both machines.

Detail: You need to pay attention to the 2 second file date difference on an NTFS file system (tell your sync program to ignore it), as well as make sure that the Linux server uses the right file type designation for the incoming files from Windows.

Solution: While you are in your /etc/samba/smb.conf file go to the bottom share descriptions and add single line under each.

Put this in the individual share section to fix timestamps that cause file syncs to copy every time from windows to linux.

fstype = samba
Remember to stop and restart your Samba server: (Linux Mepis and Ubuntu) sudo /etc/init.d/samba restart


Sample: smb.conf file (sample code):

———–My Samba smb.conf from Mepis 3.4 to 7 works!————-
;*******************section global*****************
[global]
ldap ssl = No
restrict anonymous = no
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=4096 SO_RCVBUF=4096
guest ok = yes
map to guest = Bad User
domain master = no
hosts allow = 192.168.0. 192.168.1. 192.168.2. 127.
passdb backend = tdbsam guest
dns proxy = no
printing = cups
server string =
max protocol = NT
kernel oplocks = no
; Fix your workgroup name!
workgroup = WORKGROUP
server signing = Auto
security = server
paranoid server security = no
unix charset = ISO 8859-1
panic action = /usr/share/samba/panic-action %d
preferred master = no
max connections = 8
max log size = 1000
; Fix your servername!
netbios name = MYSERVERNAME
;*******************section homes*****************
[homes]
comment = Home Directories
browseable = no
read only = no

[DriveONE]
case sensitive = no
msdfs proxy = no
path = /mnt/hdb1/MyFiles/
hide files = *.log/*.tmp/*.evt/*.bak/

[Drive_TWO]
path = /mnt/hde1/MoreFiles/
read only = no
case sensitive = no
msdfs proxy = no
fstype = Samba

[Drive_THREE]
path = /mnt/hde2/EvenMoreFiles/Subdirectory/
case sensitive = no
msdfs proxy = no

[Drive_FOUR]
path = /mnt/hdg1/MediaFilesWritable/
read only = no
case sensitive = no
msdfs proxy = no

[regularshare]
path = /home/myuser/ReadOnlyShared/
read only = yes
case sensitive = no
msdfs proxy = no
only user = yes
fstype = Samba

[Drive_Five]
case sensitive = no
msdfs proxy = no
read only = no
path = /mnt/hdc1/FilesWritable/
fstype = Samba
———–END My Samba smb.conf from Mepis 3.4 works!————-
After editing your smb.conf remember to stop and restart your Samba server: (Linux Mepis and Ubuntu) sudo /etc/init.d/samba restart

Posted in Linux tips and tricks. Tags: . No Comments »