Category: Ubuntu Tips


Should you ever need to hide files or folders in Linux

Create at hidden text file in home folder

Code: touch .hidden

All you have todo now is

ad name of any folder or file to that txt file

To view hidden files just press ctrl h

Advertisements

If you like quick access to Documents,Spreadsheet

Or any other file you use often,ad them in your

Template folder in home dir.

Now when you mouse right click the are instant available

Run “python -m SimpleHTTPServer” in any directory, and the files are now available to anybody on http://your-ip:8000

ie:
cd /home/rich/shared
python -m SimpleHTTPServer

Two commands and you can share anything anywhere with anyone 😉

UUID stands for Universally Unique IDentifier and it is used in Linux to identify disk in the /etc/fstab file.

This way, the order of the disk in the motherboard can be changed, not affecting the mount point they will have.

As can be seen, it is a good idea to have fstab using UUID instead of the /dev/xdx way to identify the disks.

Let’s learn how to add disks, to your fstab file using UUID.

List the UUIDs

There are two ways of doing this:

  1. ls -l /dev/disk/by-uuid/
  2. Being the output

    lrwxrwxrwx 1 root root 10 Sep  2 10:54 11b7eb1f-79d5-4bfe-8aa5-9235e6cccbfe -> ../../sda1
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 340cf4e2-4ee7-490c-a169-5045ebff4fac -> ../../sdb4
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 37ea6741-c1b0-4297-9f23-b36417b3c109 -> ../../sdb1
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 5b0a6c7b-d936-4470-a645-2b68db32d2c1 -> ../../sdb3
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 6db36bd8-0778-4b35-a0bd-66487002cbe0 -> ../../sdb2
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 afdc3ca9-c06e-452a-8e42-2b35ad9dac65 -> ../../sda2
    
  3. blkid
  4. Being the output

    /dev/sda1: UUID="11b7eb1f-79d5-4bfe-8aa5-9235e6cccbfe" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sda2: LABEL="/home" UUID="afdc3ca9-c06e-452a-8e42-2b35ad9dac65" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sdb1: UUID="37ea6741-c1b0-4297-9f23-b36417b3c109" TYPE="swap"
    /dev/sdb2: UUID="393ac665-f5c2-488d-b601-b59ba1d5675b" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sdb3: UUID="5b0a6c7b-d936-4470-a645-2b68db32d2c1" TYPE="ext2"
    /dev/sdb4: UUID="340cf4e2-4ee7-490c-a169-5045ebff4fac" SEC_TYPE="ext2" TYPE="ext3"
    

Now that you have the UUID edit the /etc/fstab file and make it look like this:

UUID=340cf4e2-4ee7-490c-a169-5045ebff4fac / ext3 defaults 0 1
UUID=37ea6741-c1b0-4297-9f23-b36417b3c109 swap swap defaults 0 0
UUID=5b0a6c7b-d936-4470-a645-2b68db32d2c1 /boot ext2 defaults 0 1
UUID=6db36bd8-0778-4b35-a0bd-66487002cbe0 /home ext3 defaults 0 1

Instead of:

/dev/sdb4 / ext3 defaults 0 1
/dev/sdb1 swap swap defaults 0 0
/dev/sdb3 /boot ext2 defaults 0 1
/dev/sdb2 /home ext3 defaults 0 1

If you ever need to create directory trees like this

Directory Tree

You can do this:

cd /tmp

mkdir 1

cd 1

mkdir 2

cd 2

mkdir C

or, you can just do this:

mkdir -p /tmp/1/2/3

From the man page of mkdir

-p, --parents
no error if existing, make parent directories as needed

You can also use this option to create more complicated trees. Like this one.

directory tree

Do that with this:

mkdir -p /tmp/a{1,2,B{1,2}}

According to Wikipedia:

“In computing, tar (derived from tape archive and commonly referred to as “tarball”) is both a file format (in the form of a type of archive bitstream) and the name of a program used to handle such files. The format was created in the early days of Unix and standardized by POSIX.1-1988 and later POSIX.1-2001.

Initially developed to be written directly to sequential I/O devices for tape backup purposes, it is now commonly used to collect many files into one larger file for distribution or archiving, while preserving file system information such as user and group permissions, dates, and directory structures.

We will now learn some useful command to manage and create tar files.

We will cover how to:

  1. Create a tar file with no compression
  2. Untar an uncompressed tar file
  3. Create a gzipped tar file
  4. Untar a gzipped tar file
  5. Create a bzipped tar file
  6. Untar a bzipeed tar file
  7. Listing the contents of a tar file
  8. Extracting the files to a specific directory

1. Create a tar with no compression

tar cvf tar-file.tar directory/

2. Untar an uncompressed tar file

tar xvf tar-file.tar

3. Create a gzipped tar file

tar cvzf tar-file.tar.gz /directory

4. Untar a gzipped tar file

tar xvzf tar-file.tar.gz

5. Create a bzipped tar file

tar cvjf tar-file.tar.bz /directory

6. Untar a bzipeed tar file

tar xvjf tar-file.tar.bz

7. Listing the contents of a tar file

tar tvf tar-file.tar

For uncompressed tar file

tar tvfz tar-file.tar

For gzipped tar files

tar tvfj tar-file.tar

For jzipped tar files

8. Extracting the files to a specific directory

tar xvf -C tmp/som/other/directory tar-file.tar.gz

For uncompressed tar files

tar xvzf -C tmp/som/other/directory tar-file.tar.gz

For gzipped tar files

tar xvjf -C tmp/som/other/directory tar-file.tar.gz

For jzipped tar files

The options used

-c
create a new archive
-v
verbosely list files processed
-f
use archive file or device ARCHIVE
-x
eXtract the file
-z
–gzip, –gunzip –ungzip
-j
–bzip2
-C
change to directory DIR

1. We will have to edit grub configuration. Open a terminal and paste this: sudo gedit /etc/default/grub . Hit Enter. It will open grub preferences in Gedit.

2. Locate the line “# GRUB_GFXMODE=800×600” (resolution may be different). U have to change the resolution to actual resolution of your screen, for example mine is 1240×1024. Next step is to uncomment this line (remove the # and and the empty space if is, so the letter G of the word GRUB will be the first letter in this line). After u r done, save the file and close.

3. Now paste this line in terminal: sudo gedit /etc/grub.d/00_header .
Hit Enter. It will open a text file with a lot of stuff. Use the search option at the top of the window to locate this line: gfxmode=${GRUB_GFXMODE} . After u successfully find it, u will have to add this line: “set gfxpayload=keep” (of course without the ” sign) just under the gfxmode=${GRUB_GFXMODE}. Make it look like this:

set gfxmode=${GRUB_GFXMODE}
set gfxpayload=keep

Now, save the file and close.

4. In terminal paste: sudo update-grub . Hit enter, it will generate new grub.cfg file so the changes u made will be saved. Reboot and enjoy sexy boot screen resolution.

!!!!In case u don’t know what is your screen resolution! Go to System – Administration – NVidia X serever settings and click on the NVidia X sever display configuration tab)) it will show u your screen reso

To disable the login screen user list in Ubuntu 10.04, simply run the following command, entering your password when prompted:

sudo -u gdm gconftool-2 --set --type boolean /apps/gdm/simple-greeter/disable_user_list true

The next time you log in you’ll be prompted to enter your username and password, instead of selecting your username from a list.

If you’re not familiar with how DropBox works, it’s simple: You create a free account with DropBox, and install a small app on your computer. This app creates a folder on your computer (wherever you choose) and monitors that folder at all times. Whenever you change the contents of this folder, by adding, modifying or deleting files, DropBox automatically syncs these changes to your account’s folder on their servers. Additionally, any other computer logged into that same account will have their DropBox folder synced as well. There’s nothing earthshaking about this capability,  but the whole process is amazingly simple and makes collaboration an absolute breeze.

Still, with a little creativity, DropBox can be a lot more than just a way to move files from one computer to another. We’ve compiled a list of five of the coolest DropBox tricks we’ve heard of so far, so read on to find out how you can use DropBox and other free software to recover a stolen laptop, organize your Torrents, keep your passwords safe, and more.

1. Keep all your passwords safe

Everyone knows that good password security requires that you use passwords that are A) long, B) complicated, and C) different for every website and service you use. Of course, these three requirements also make it a total pain to memorize all the passwords you need, meaning that most people don’t follow the rules, either using one password across many services (a security risk) or writing their passwords down near the computer (also a security risk).

That’s where KeePass comes in. KeePass is a free, open source password safe. It allows you to generate a unique, totally random password for every site or service you use, while only requiring you to remember a single master passphrase. Whenever you attempt to log into a service, KeePass asks for your master passphrase, then automatically enters the appropriate password from your safe.

That’s all well and good, but what do you do if you frequently use two different computers (say, a desktop and a laptop)? You could use a USB drive to keep your KeePass password archive with you at all times, but that’s one more little bit of hardware you have to keep track of. Instead, use DropBox to keep an up-to-date copy of your password file on both computers, at all times. Just tell KeePass to save your password archive somewhere in your DropBox synced folder.

Worried about security? Fuhgeddaboutit. KeePass saves your password in an archive encrypted with nigh-unbreakable AES 256-hit encryption. That means that as long as you pick a strong, long password, getting a hold of your KeePass file won’t do a hacker a bit of good.

2. Catch Laptop Thieves

As PC enthusiasts, nothing gets our blood boiling like tales of stolen laptop computers. With DropBox, though, there’s a chance for sweet, sweet revenge. The trick is to set up a keylogger on your own machine, and set it to save its log files into the Dropbox shared folder. If anyone ever steals your laptop, your Dropbox folder will give you a detailed look at what the thief is doing with it. If the cretin connects to a service such as MySpace (and our personal research indicates that cretins just love MySpace) then you’ll know exactly who stole your notebook.

By letting Dropbox handle the syncing, you don’t have to let an internet-enabled keylogger through your firewall (because who knows who it could be sending data too). Of course, keyloggers are pretty sketchy business, so if you want to try this trick out you’ll have to track one down on your own.

3. Access an Encrypted Drive, Anywhere

We like Dropbox. We like TrueCrypt. So what if… What if, we were to use the two together? Crazy, we know, but by combining the top-notch encryption of TrueCrypt with the easy syncing of Dropbox, you can create an encrypted drive accessible from any computer.

To do this, just download the TrueCrypt executable, run it, and choose to Extract it (rather than install it) to your Dropbox folder. From there, make an encrypted volume, as described in this article. This will allow you to run TrueCrypt and mount your encrypted volume straight off of the Dropbox folder, on any machine.

There’s one thing you should note about this method: First, Whenever Dropbox updates a file, it first compares the old file and the new, then only uploads or download only the bits that have changed. On the one hand, this is good because it means that you don’t have to re-upload your entire 500MB encrypted volume every time you add something to it. On the other hand, a hacker could (theoretically) see how the encrypted data is changing as you add or change files in the volume; an encryption no-no. Still, this definitely not something you have to worry about if you’re just looking for a little extra security for your Dropbox files.

Read on to find out how you can use Dropbox to control a BitTorrent and sync up all your instant messaging logs!

4. Control a BitTorrent Client Remotely

How often have you found yourself sitting at work, only to find out that a file you’re interested (a demo for a game you’re excited about, for instance) has just become available online. Sure, you could sit there patiently, and wait until you get home to download it; but why bother waiting when you could have it ready for you as soon as you get there. Most of the big BitTorrent clients have some sort of web-based control, but those can be tricky to set up, and require that you have a static IP (or set up a DynDNS account). Using DropBox, it’s much easier.

Here’s what you’ll need to do: First, make sure you have a BitTorrent client capable of automatically loading .torrent files from a folder. All the big ones are capable of this, including uTorrent, Vuze, and the standard BitTorrent client. Next, set it up to monitor your DropBox, or a folder in your DropBox (My Documents/My Dropbox/Torrents for instance) and automatically open any .torrent file added to that folder.

Now, if you see a file you want to grab, just download the .torrent file to your Dropbox/Torrents folder, and your home PC will start the download as soon as DropBox syncs. It’s as simple as that.

Of course, this method requires that you leave you computer on all day long, a decidedly environmentally-unfriendly practice that we don’t recommend. But If you’re anticipating the need to download something (a beta test for a new MMO, maybe?) we won’t fault you for making a one-day exception.

5. Access your IM logs from any computer

A lot of people use instant messaging to keep in touch with their coworkers during the day. We certainly do here at the Maximum PC office, but we’re sure the same can be said for many less-technically-forward offices as well. Because of that, there are times when, while you’re at home, you want to remember something from a conversation you had while you were at work, but you can’t, because your IM logs are stored on your work computer.

That doesn’t have to be the case, though. If you use Pidgin, a free, open source multi-protocol IM client, you can tell it to save its logs in a folder in your Dropbox. As long as Pidgin is set up that way on all of your computers, they will all share access to the same logs.

Actually setting it up so that Pidgin saves your logs somewhere other than the default location is a little trickier than you might imagine, though. You’ll need to change the PURPLEHOME environment variable on your system, which defines where Pidgin will save its configuration files and logs. To do this, open the control panel and select System. Then select the Advanced tab, and click on Environment Variables. Now, click New under the System Variables box. In the Variable Name field, enter PURPLEHOME and in the Variable Value field, enter the location of your Dropbox folder. Now Pidgin will use a folder inside your Dropbox called .purple to save its data.

If you’re ok working from a fresh install of Pidgin, that’s all you’ll need to do. If you have existing settings and logs that you want to keep using, just copy the .purple folder from its default directory (Application Data) to your Dropbox directory.

Get Dropbox here:

https://www.dropbox.com/referrals/NTk5Mzc1Nzk

You can do it simply from your terminal window.

sudo shutdown now

to shutdown your machine NOW.

where hh:mm is the time on 24hr clock to shutdown at 7:50 you need to type

sudo shutdown hh:mm
sudo shutdown 7:50.

where m is the minutes. If you type

sudo shutdown +m
sudo shutdown +120

the machine will shutdown itself in 120 minutes.

And for the non terminal guys there is an application for doing this and more its called Gshutdown.

You can install Gshutdown by simply running the

sudo apt-get install gshutdown

command in your terminal or through Synaptic Package Manager.