Search the web with Google

Android install

Android installation weblog

Enter your email address:

Jeroen´s weblog

Ubuntu install

Ubuntu installation weblog

Friday, June 17, 2011

Usefull commandline commands for Ubuntu

1. Making a Temporary Filesystem (Ramdisk)

There are several reasons to make a temporary RAM-based filesystem such as fast read/write times or to guarantee that the files will not persist after reboot. Making such a “fake” filesystem is easy, and just requires one command.
mount -t tmpfs tmpfs /mytemppartition -o size=1024m
Where /mytemppartion is the location you wish to mount (it must already exist) and 1024m is the desired size of the ramdisk.

2. Quickly Scheduling Commands

Linux pros almost certainly know the at command, it lets you set a specific time for a job to be run. You simply say what to do and when to do it, and at takes care of the rest. Its usage can be confusing for some, so here’s one common way of scheduling a task with at.
at 12:30 #Enter key
If you want to verify that it worked, you can easily list the sceduled jobs with
at -l

3. Re-run Previous Commands

Perhaps you ran a long complicated command, but forgot to preface it with sudo, or maybe you didn’t add some necessary options to the end. Instead of retyping the whole thing or going back through your shell history, you can use “double bangs” to represent your last command.
mkdir /etc/myDir
#Permission denied
sudo !!
If you’re the type who tracks your command history numbers, you can use the same approach to recall any previous command by referencing its number:

4. Find the PID of a Process

If you need to kill a particular process but don’t have its PID, there’s a simple shortcut to find it – the pgrep command. It doesn’t do anything that can’t be done with a combination of ps and grep, but every little bit helps.

5.  Show Listening Ports and their Processes

If you need to see what’s listening for connections on your system, and the processes handling those connections, the old trusty netstat tool is up to the job. Try
netstat -tlnp
to see just such a list.

6. SSH Without Passwords

Many people, such as this author, use SSH on a nearly constant basis. It’s a great tool, there’s no denying that, but having to constantly retype your passwords can get annoying. Instead, you can simply copy your (public) SSH information to the remote machine, allowing it to authenticate you without requiring your password, and all you need is a single command.
ssh-copy-id username@remote-machine

No comments:

Post a Comment