LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Console: Hints and Tips (https://www.linuxquestions.org/questions/linux-newbie-8/console-hints-and-tips-141539/)

Balkman 02-02-2004 05:25 PM

Console: Hints and Tips
 
I'm making this post for anyone who wishes to tell the linux community a cool shortcut or tip that will make any newbie's life easier in the console. I'll start off with one I just learned.

Within any directory, if you type a little bit of the file name and press <tab> the console will automatcially fill in the rest of the file so you dont so happen to have a typo.

example:
if you want to uncompress the file MPlayer-0.92.tar.bz2. All you would have to type is:
MPla<tab> and the console will print out "MPlayer-0.92.tar.bz2"

<tab> = press the tab key

frieza 02-02-2004 05:48 PM

the 'history' command can also be your friend in the console :)
history keeps track of your last 1000 some commands and allows you to access them by at least 2 means
1 is 'history | less' (history pipe less), look at the number in front of the desired command then type in !XXX (XXX being the number)
the other simply being the up and down arrow keys to scroll through the most recent commands as with some web browsers :)

statmobile 02-02-2004 11:14 PM

if you want to get right to the last directory you were in type:

cd -

There are hundreds of unbelievable tips here:
LQ Tips and Tricks

It'll take a while to go through it, but it's definitely worth it. I'm still trying to summarize all of them, and organize them. Then I can throw it together for a little reference. So many useful features built into the bash shell, too little time to learn and use them all!!!

slakmagik 02-02-2004 11:22 PM

'Screen' rocks.

Read the bash man page (if that's your shell) constantly.

Readline and history and the editing commands are huge, as frieza mentions. (Though the default histsize is 500 putting -
export HISTFILESIZE=1000
export HISTIGNORE=\&
export HISTSIZE=1000
- in your configs is useful.

Spend time on your ~/.bash_profile or however you configure your shell.

The man page will tell you about shopts and your configuration can set them up. In my ~/.bash_profile, I have 'shopt -s checkwinsize cmdhist extglob histappend histverify' and maybe should add 'cdspell' and others.

One of the coolest things there is is the semi-colon. The command line is not just for 'ls'. As a trivial example, I was in ~/.icons in aterm looking to add a calculator icon to Ice's little systray thing. So I typed
for f in `find -name *[Cc]alc*`; do xzgv $f; done
and got a slideshow of all my calculator icons, regardless of what subdir they were in. The command line kicks whether in console or a GUI.

You can get a bang out of bangs. '!cat' will re-execute your last cat command (and !wh will execute your last wh-atever command) or, with 'histverify' on, will load the command and you can choose to enter or edit it.

The Linux console/bash is just a blast. :D

SciYro 02-03-2004 12:12 AM

also to add to teh <tab> thingy, the star will also will in the last of the file name * , only it wont show up, it can also be used to select fiels of the same start, rm -fvr lilo* deleted everyhting beigning with lilo,

i dono if this makes it easyer but in ur bash profile the PS1 variable is used to customize the bash promt,

lugoteehalt 02-03-2004 07:50 AM

Quote:

the 'history' command can also be your friend in the console
One good use of it is to do 'ctrl-r'; this starts an incremental backward search through the history list. For examply typing shu will probably be enough to get 'shutdown -r now'; doing ctrl-r again will probably get you 'shutdown -h now'. Personally use this all the time.:)


All times are GMT -5. The time now is 01:21 AM.