28 Comments

philluminati Said,
March 18th, 2008 @1:35 pm  

You can use the last argument from the last command by refering to it as $_

so you only need to type a long path like this once:

cp assignment.htm /home/phill/reports/2008/

and do:

cd $_

to go straight to the 2008 folder as well. You can use this however you like. Always the last argument of the command above.

mygif
Grey Said,
March 21st, 2008 @2:23 pm  

I find it horribly saddening that people are falling away from the command line. I personally use most of these commands multiple times a day. To think that these are the ones that people don’t use…

mygif
mrozekma Said,
April 23rd, 2008 @3:01 pm  

philluminati mentioned using $_ for the last argument of the last command; you can also hit Alt+. to quickly paste it at the cursor.

mygif
bit-head Said,
April 24th, 2008 @11:52 am  

I almost find this article’s title offensive. I too use most of these commands daily because my job requires I be efficient. Put it this way, its much easier to click on the wrong icon then it is to type the wrong program name. How often do you type “firefox” when you really wanted to type “xterm”?

mygif
Steve K Said,
April 24th, 2008 @12:57 pm  

Should have mentioned using touch to make a new empty file - just the thing for new kids playing around. And speaking of things most users don’t use, how about linx and wget? Massive time savers, plus you can surf the web and download stuff without it being obvious to anyone who may wander past. ;o)

mygif
getoffmylawn Said,
April 24th, 2008 @1:36 pm  

In all fairness, I don’t see how you can categorize any of these as really being “Linux” commands. Hell, most aren’t really OS commands, per se.

The only ones that are really OS commands would be the pgrep, mkdir and touch. Of those, the only one that’s even remotely specifically a Linux command is `pgrep`. Even that’s kind of a stretch, as several other *N*X’s have a pgrep implementation. Every *N*X implements mkdir and touch in the ways described above.

The rest are “shell built-ins” - specifically, Bash. If you’re one of the (admittedly rare) users that changes their shell, your “Linux commands” likely won’t work (e.g., if someone installs and uses pdksh). While Bash was initially unique to Linux, the functionalities that you’re describing are functionalities that Bash borrowed from other shells (e.g., Tenex C-Shell). So, again: not really “Linux commands”.

mygif
Oshu Said,
April 24th, 2008 @1:46 pm  

You are not quite right about ctrl-u. It doesn’t delete the entire line, it deletes everything to the left of the cursor. So it will only delete the entire line when the cursor is at the end of the line. Also, hitting ctrl-k will delete everything to the right of the cursor.

mygif
Stu Said,
April 24th, 2008 @2:02 pm  

One cool one I recently learned is fc, fc will open the last command from your shell history in the default editor. You can also specify a text editor. You can add a history line number or the first few letters of the most recent command. For example “fc -e kate wget” will open kate with the last shell command starting with wget. You can edit the command, and when you save and close kate, the command will execute.

mygif
ts Said,
April 24th, 2008 @6:37 pm  

Oshu is right about ctrl+u; it only deletes everything to the left of the cursor. This is especially useful when you know you fat fingered your password and you want to quickly start over. Also works on cisco routers.

mygif
des Said,
April 26th, 2008 @2:41 pm  

The !! command is very useful when you forget to start a commando with “sudo” in Ubuntu:

apt-get update
sudo !!

And yes, it looks like you are shouting: “I MEANT TO USE SUDO!” ;)

mygif
Joe Said,
April 26th, 2008 @4:02 pm  

Another useful command is ‘&’ (ampersand)
Ending a command with ‘&’ runs the command with a new PID, releasing the command line back to you. Useful for running a background process.

mygif
Slightcrazed Said,
April 28th, 2008 @12:32 pm  

The one command *nix DOESN’T have but NEEDS:

#!/bin/ksh
mkdir “$1″
cd “$1″

Save the above as an executable script (I call mine mkcd) and use it:

$ mkcd dir

Stupid, you say? I thought so, and now I get ticked whenever I’m on someone else’s system that DOESN’T have it. How many times to you end up having to make a directory and then immediately cd into it? Quite a few, if you’re like me. I know the above doesn’t have any error checking, but it’s for my own use. I have a similar script that acts like mv, only it makes a directory, moves the file into it, and then cds you into that directory.

If there are other ways of doing these things, I’m open to ideas…….

mygif
ed Said,
April 29th, 2008 @1:01 pm  

I think cd with no arguments takes you to your home directory on most systems (equivalent to cd ~), not last directory you where in as stated here.

mygif
Marc Said,
April 30th, 2008 @5:56 am  

I think it’s “cd -” not “cd” that is written in the 10 commands…

mygif
deez Said,
May 10th, 2008 @8:28 am  

I never knew about +z+z in vi before. I suppose its just as many kepresses as exiting insert mode and typing : w

mygif
saurabh Said,
May 13th, 2008 @12:38 pm  

Here’s a little-known but extremely useful one:

Sometimes your terminal gets borked, for whatever reason. It gets put into a different display mode, it stops printing typed characters, it won’t display line feeds, etc. Instead of killing and re-starting your terminal session, you can merely type the command ‘reset’. This will reset your terminal back to its defaults, clear the screen, and everything will be as it was before.

mygif
May 15th, 2008 @8:18 pm  

Slightcrazed, about your mkcd script i use mkdir dir && cd dir

the second command execute only if the frist execute ok

just like
sudo aptitude update && sudo aptitude safe-upgreade

mygif
zize Said,
May 31st, 2008 @2:24 pm  

I cant say i never used all these command.
i might not use everyone every day, but it almost pisses me off all these elitist users who have to post to this blog and point out that it is a useless post because _they_ know everything about these commands so everyone else should know them. have you ever stopped to think about that the linux platform gathers new users every day, and that these users need sources to learn things?

cheers

mygif
Frank Said,
June 6th, 2008 @4:42 am  

When the title says “10 Linux Commands You Probably Don’t Use” I think what’s meant is ones you probably don’t know. Previous comments seem to suggest they think it means you would use a GUI for them instead of a command.

mygif
ketan Said,
June 8th, 2008 @1:54 pm  

ctrl+l will clear the screen.

mygif
yeah_boy Said,
June 14th, 2008 @9:23 am  

I don’t use the command line much (I am one of those relatively new linux users), but I did learn something from this post and the comments.

@Ricardo Figueroa:
Couldn’t you use {mkdir dir && cd $_} instead of {mkdir dir && cd dir} so as to avoid having to re-type the directory name — which you could possibly mis-type the second time?

mygif
ATOzTOA Said,
June 27th, 2008 @5:33 am  

Actually, I never knew most of these tips, I use CLI often… thx bud

You can save and exit vi by :x …. easier than shift+w+w

mygif
ForiPepe Said,
October 5th, 2008 @9:48 am  

If you are in a terminal, and you use a command, it occupies the terminal:
gedit somefile
If you use & at the end of the command, you can run the program and use the terminal in the same time:
gedit somefile&
If you forget to put & on the end of the command, and you would like to use the terminal without closing the application, press:
CTRL-z
The job stopped. You will see something like this:
[1]+ Stopped gedit somefile
Where 1 is the job specifier.
After that you can start the job with:
fg 1
and your terminal will be reserved again. Or you can use:
bg 1
and your program and the terminal will be available in the same time.

mygif
Vinas Said,
October 7th, 2008 @4:15 am  

What about the built in ps and grep? Surely it’s better to know how to use grep with other commands… ps -ax |grep fox

mygif
Pingback & Trackback
May 28th, 2008 @6:46 am  
mygif
June 10th, 2008 @9:23 pm  
mygif

Random Post

Leave Your Comments Below

Please Note: All comments will be hand modified by our authors so any unsuitable comments will be removed and you comments will be appreared after approved