A few terminal tips

In the post I’m going to tell you how to use Ubuntu to wake you up in the morning, how to merge videos, how to manage another computer from yours and how to shorten commands you use a lot.

updated: 07/08/08

note: please don’t copy/paste the commands, wordpress reformats the text and copy pasting some commands will not work.

1. Use Ubuntu to wake you up in the morning.

For that you can use the sleep command.

The sleep command will executes commands after x amount of time.

Lets say you want vlc to play a song in 8 hours.

You would simply use this command:

sleep 8h && vlc /path/to/music.mp3

or if you’re a hardcore mpd/mpc user

sleep 8h && mpc play 153

This will start playing song 153 in the loaded playlist.

Easy enough, no?

(also see point 4)

2. How to merge videos together

You’ll need to install an application first.

sudo apt-get install mencoder

Then use this command merge the videos:

mencoder -ovc lavc -oac lavc /path/to/vid1.avi /path/to/vid2.avi -o video.avi

This will merge the two videos into one big video called video.avi

3. How to manage another computer from yours?

Again, pretty straight forward.

You’ll need to install some programs first (on both computers).

sudo apt-get install openssh-server openssh-client

Then you would open a terminal and use it to log into the other pc.

You would use this command

ssh -x username@server

So in my case that would be

ssh -x rw@192.168.1.3

Then you can start changing things around.

Modify xorg, shut down the other computer, …

Because you also added “-x” to the command, you can start graphical applications from the other computer on your.

This might come in handy for a lot of things. I only use it to access my firefox bookmarks from the other pc on mine.

If you need to copy files, you should read this.

(for the graphical way to do this: link)

4. Make Ubuntu talk to you

I guess there is some use for this, I just don’t know what.

But it can be fun.

Use this command:

espeak “hello world”

Instead of hello world, you can paste entire pages from you open office documents (highlight, middleclick) between the ” “.

You could also use this to wake you up.

sleep 8h && espeak “Wake up buddy”

You’ll need to be sure you put the volume to max.

To make things more interesting, you could add stuff to the previous command.

sleep 8h && espeak “wake up buddy” && sleep 30s && espeak “now” && sleep 30s && vlc /path/to/music/file/that/will/piss/you/off/in/the/morning.mp3

That should ensure you are up.

5. Shorten commands you use a lot.

Let’s say you’re a die hard espead user (are there any of those around?).

Instead of having to type

espeak “hello world”

you could use

e “hello world”

How can this be?

Ah, padawan, you can change these kinds of things in your bashrc file.

It’s located in /home/username/.bashrc .

Did you notice the “.”, that means it’s hidden. So use the “ctrl + h” keyboard shortcut to view it.

Open that file with you favorite editor and in the bottom of the file, add this:

# Shortened commands

alias espeak=’e’

Putting a “# before a line comments it out, meaning that it won’t be used.

6. Removing some unneeded files

Title really says it all.

The first two commands speak for themselfs, the third command will purge unneeded dependencies.

sudo apt-get clean

sudo apt-get autoremove

export PACKAGES=$(dpkg -l | awk ‘{if ($1 == “rc”) print $2″ “}’ | tr -d ‘\n’)
[ -n “$PACKAGES” ] && sudo aptitude purge $PACKAGES

Got any more tips?

Feel free to share them in the comments.

  1. The problem with #1 is you need to calculate the sleep time because you need to know ‘how long must it sleeep to wake me up at this hour?’.

    To schedule commands on specific times use the cron utility http://www.adminschoice.com/docs/crontab.htm

    • linuxowns
    • August 5th, 2008

    I know, but still the sleep command can be useful to use with vlc or something as a clock.

    But you’re right a cron job would do to.

    I’m planning on doing a post about cron jobs this week.

  2. Great tips, some cool stuff here :]

  3. thank for good tip, for human beings 🙂

    • kendon
    • August 6th, 2008

    alias e=’espeak’

    would be the correct syntax to define an alias, at least on my ubuntu’s bash. notice it’s not ’ but ‘

    • kendon
    • August 6th, 2008

    hm seems that your font messes that up. it is not an “upper comma”, it is this little straight line. on german keyboard it’s on the #key with shift.

    • linuxowns
    • August 6th, 2008

    @kendon

    I know, wordpress formats it like that.

    • jimmy
    • February 6th, 2009

    it should be a capital ‘X’ instead of a ‘x’.
    the small ‘x’ disables X11 forwarding.

    so instead of:
    ssh -x username@server

    it should be:
    ssh -X username@server

    http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&sektion=1

  4. If you are rude to me or anyone in my circle, ditto. ,

  5. Thanks for this helpful infromation and I’ve scraped it with scrapebook(firefox addon) for studying. I am new to ubuntu, can you recommend me books about ubuntu? Thanks.

    • soundarapandian
    • April 7th, 2011

    Hi great tips.Very useful.Thanks

  1. December 18th, 2008

Leave a reply to Angus Cancel reply