Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Console / shell tips & tricks

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
376 posts
  • Page 1 of 16
    • Jump to page:
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 16
  • Next
Author
Message
carambola5
Apprentice
Apprentice
User avatar
Posts: 214
Joined: Wed Jul 10, 2002 8:53 pm

Console / shell tips & tricks

  • Quote

Post by carambola5 » Tue Sep 17, 2002 11:36 pm

Yes, we all know how to alias stuff in /etc/profile or ~/.bashrc or whatever. Some favorites of (seemingly) everyone are:

Code: Select all

alias ls='ls --color'
alias sl='ls --color'
The list is brief, but that's where the rest of this thread comes into play: What are some quick little console (if you want X-tricks, start another thread, please!) tricks that you employ?

Here are some of mine:
script called "remote" that can optionally take in an argument. If there is an argument, it's a nickname for an ssh server. If there is no argument, list the predefined ssh servers and pick from the menu. This is useful if you like to forward ports often.
alias rm='rm -f' I'm feeling lucky :D


EDIT: Title was "quick console tricks" --pjp
Top
nitro322
l33t
l33t
User avatar
Posts: 605
Joined: Wed Jul 24, 2002 2:06 am
Location: USA
Contact:
Contact nitro322
Website

  • Quote

Post by nitro322 » Wed Sep 18, 2002 5:14 am

Code: Select all

alias 2000='su -c "lilo -R 2000" && reboot'
reboot to Windows 2000 without the LILO prompt
2000 = the lilo name for my Windows 2000 entry

Code: Select all

alias c='clear'
alias md='mkdir'
alias rd='rmdir'
alias dir='ls -Alh --color | more'
I'm lazy :-)

Code: Select all

alias gpm='sudo /etc/init.d/gpm start'
alias halt='sudo /sbin/halt'
alias reboot='sudo /sbin/reboot'
alias renet='sudo /etc/init.d/net.eth0 restart'
more various shortcuts to save me time

Code: Select all

alias kernel_comp='cd /usr/src/linux/ && cp .config .. && make clean && make mrproper && cp ../.config . && make menuconfig && make dep && make bzImage modules modules_install && cp System.map /boot/System.map-020916 && cp arch/i386/boot/bzImage /boot/bzImage-020916 && lilo && echo "finished"'
who's your daddy? :wink:

I guess that's just about it. I also run my console at 1024x768 resolution with 8-bit color, which gives me a LOT more room to work, in addition to being purtier. If you haven't noticed, the left and right windows keys on your keyboard will change you to the virtual terminal to the left and right of your current one. Nice.
Top
dioxmat
Bodhisattva
Bodhisattva
Posts: 709
Joined: Sat May 04, 2002 11:15 am
Location: /home/mat
Contact:
Contact dioxmat
Website

  • Quote

Post by dioxmat » Wed Sep 18, 2002 8:18 am

nitro322 wrote:

Code: Select all

alias kernel_comp='cd /usr/src/linux/ && cp .config .. && make clean && make mrproper && cp ../.config . && make menuconfig && make dep && make bzImage modules modules_install && cp System.map /boot/System.map-020916 && cp arch/i386/boot/bzImage /boot/bzImage-020916 && lilo && echo "finished"'
who's your daddy? :wink:
nah, you forgot to evaluate the time it took :)
Top
fmalabre
Guru
Guru
User avatar
Posts: 376
Joined: Wed Jun 19, 2002 7:11 pm
Location: Chicago
Contact:
Contact fmalabre
Website

  • Quote

Post by fmalabre » Wed Sep 18, 2002 3:57 pm

nitro322 wrote:reboot to Windows 2000 without the LILO prompt
Can we do the same thing with Grub?
Top
pjp
Administrator
Administrator
User avatar
Posts: 20668
Joined: Tue Apr 16, 2002 10:35 pm

  • Quote

Post by pjp » Wed Sep 18, 2002 6:56 pm

I could've sworn I'd seen it done somewhere, but I'm not finding it.
Quis separabit? Quo animo?
Top
rojaro
l33t
l33t
Posts: 732
Joined: Mon May 06, 2002 4:56 pm
Contact:
Contact rojaro
Website

  • Quote

Post by rojaro » Wed Sep 18, 2002 8:24 pm

there is no such function in grub and there are just two "halfway methods" which work ... well just half the way ...

1. is to use multiple menu.lst files and a shellscript which exchanges the config files (which is pretty easy to implement)

2. use a shellscript which changes the "default"-parameter in the menu.lst file using sed (imho the nicer way). this shellscript should reset the menu.lst to the real default when called without parameters and you could add it to /etc/conf.d/localstart to change the parameter back to default automatically on next linuxboot ...

sure you'll see why this is only a halfway solution ...

[edit: ... just filed a feature request at their bugzilla]
Last edited by rojaro on Wed Sep 18, 2002 8:37 pm, edited 1 time in total.
A mathematician is a machine for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970)
Top
NickDaFish
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 112
Joined: Thu Sep 12, 2002 4:24 pm
Location: Boston, USA

  • Quote

Post by NickDaFish » Wed Sep 18, 2002 8:26 pm

alias ls='ls --color'
:D YES! Many thanks! I've been trying to work out how to make bash do that for AGES! It's default in RedHat and I've been missing it ever since I went over to Gentoo... Too many other things to figure out first :wink: so I never go to it.

BTW Does anyone know how to get my Home key to work with in a PuTTY SSH session? I think it's something to do with inputrc..... I have Ctrl-a to get me by for now but I'd it would be nice to get my keyboard to work as advertised :?
Top
carambola5
Apprentice
Apprentice
User avatar
Posts: 214
Joined: Wed Jul 10, 2002 8:53 pm

forgot one

  • Quote

Post by carambola5 » Fri Sep 20, 2002 5:28 am

(Using lynx while bootstrapping, so I don't know how this'll turn out.)

I forgot one very key alias in my first post:

Code: Select all

alias pico='nano -w'
And life just became much easier. : )
Top
phong
Bodhisattva
Bodhisattva
User avatar
Posts: 778
Joined: Tue Jul 16, 2002 6:51 pm
Location: Michigan - 15 & Ryan
Contact:
Contact phong
Website

  • Quote

Post by phong » Fri Sep 20, 2002 2:41 pm

I have lots of aliases to save myself some typing, many are either from DOS or even from .bat files I made in the DOS days for the same purpose:

Code: Select all

alias vi='vim -o -X'
alias vim='vim -o -X'
alias vimdiff='vimdiff -X'
alias dir='ls --color -Flh'
alias dirh='ls --color -Flah'
alias di='dir' # my most common command line typo is hitting enter before 'r' in dir
alias r=''
alias cls='clear' # actually, I usually just hit ctrl-l
alias x='exit'
alias rd='rmdir'
alias md='mkdir'
alias h='history'
alias mo='more'
alias le='less'
alias ks='kfmclient exec' # like the windows "start" command
alias nc='mc'

alias cd/='cd /'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
"An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer
Top
tactless
l33t
l33t
User avatar
Posts: 642
Joined: Sun Jul 14, 2002 11:13 pm
Location: Mitzpe Adi, Israel
Contact:
Contact tactless
Website

  • Quote

Post by tactless » Mon Sep 23, 2002 6:25 am

Not really a "trick", but here's something I put in my bashrc:

Code: Select all

fortune
Great way to start the day :)[/code]
Tactless

"If it wasn't for fog, the world would run at a really crappy framerate."

Jabber: tactless@amessage.info
Top
wbsoft
n00b
n00b
User avatar
Posts: 73
Joined: Mon Aug 26, 2002 7:29 pm
Location: the Netherlands
Contact:
Contact wbsoft
Website

  • Quote

Post by wbsoft » Mon Sep 23, 2002 8:03 am

Code: Select all

nd() { test -d "$1" || mkdir "$1" && cd "$1" ; }
alias o="less -iMS"
nX()
{
  for i in `seq 0 9`
  do
    if [ ! -e "/tmp/.X${i}-lock" ] ; then
      XFree86 ":$i" -query localhost &
      break
    fi
  done
}
the last one, nX, starts a new X login on a new display. (You should add localhost to /etc/X11/xdm/Xaccess)
Top
squanto
Guru
Guru
User avatar
Posts: 524
Joined: Sat Apr 20, 2002 9:25 pm
Location: Rochester, NY, USA

  • Quote

Post by squanto » Fri Sep 27, 2002 4:47 am

I read somewhere how to customize bash, with like the full current directory path, the time, and a whole bunch of other things. Any one want to give me a quick heads up to an article on how to do this?
I think it fits in with neat things to do with customizing your shell.

thanks!
Top
carlivar
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 92
Joined: Mon Jul 22, 2002 7:32 pm
Location: Burbank, California
Contact:
Contact carlivar
Website

  • Quote

Post by carlivar » Fri Sep 27, 2002 7:34 am

squanto wrote:I read somewhere how to customize bash, with like the full current directory path, the time, and a whole bunch of other things. Any one want to give me a quick heads up to an article on how to do this?
Go here for a very nice thread with many bash prompt examples.

Carl
"It is difficult to make our material condition better by the best law, but it is easy enough to ruin it by bad laws." - Theodore Roosevelt
Top
squanto
Guru
Guru
User avatar
Posts: 524
Joined: Sat Apr 20, 2002 9:25 pm
Location: Rochester, NY, USA

  • Quote

Post by squanto » Mon Sep 30, 2002 1:13 am

carlivar wrote:
squanto wrote:I read somewhere how to customize bash, with like the full current directory path, the time, and a whole bunch of other things. Any one want to give me a quick heads up to an article on how to do this?
Go here for a very nice thread with many bash prompt examples.

Carl
Hey, thanks!
I read an article about customizing bash in CPU mag, but misplaced the article.
I don't like how gnome's term doesn't list anything.
as for my aliases: alias sshserver="ssh my.server.name.edu"
so I can ssh into my game server ;) (modified obviously)

Andrew
Top
NiklasH
Apprentice
Apprentice
User avatar
Posts: 211
Joined: Fri Aug 30, 2002 7:52 am
Location: On top of something
Contact:
Contact NiklasH
Website

  • Quote

Post by NiklasH » Wed Oct 02, 2002 9:48 am

wbsoft wrote:

Code: Select all

nd() { test -d "$1" || mkdir "$1" && cd "$1" ; }
alias o="less -iMS"
nX()
{
  for i in `seq 0 9`
  do
    if [ ! -e "/tmp/.X${i}-lock" ] ; then
      XFree86 ":$i" -query localhost &
      break
    fi
  done
}
the last one, nX, starts a new X login on a new display. (You should add localhost to /etc/X11/xdm/Xaccess)
I can't get this to work...
The nX function starts a new X window, but I get no login prompt (gdm, in my case).
Am I doing something wrong? I tried to add just 'localhost' in Xaccess. Should I add something more? I also tried to add CHOOSER localhost, but that didn't work either.
Maybe I'm just stupid... :? But I would really like this to work, so any help is very appreciated!
Top
klieber
Bodhisattva
Bodhisattva
User avatar
Posts: 3657
Joined: Wed Apr 17, 2002 4:48 pm
Location: San Francisco, CA
Contact:
Contact klieber
Website

  • Quote

Post by klieber » Wed Oct 02, 2002 5:32 pm

I find it remarkable how many people don't use the history command. That, combined with the '!n' to re-issue a frequently-used command saves me tons and tons of time.

man history if you have no idea what I'm talking about.

--kurt
The problem with political jokes is that they get elected
Top
carambola5
Apprentice
Apprentice
User avatar
Posts: 214
Joined: Wed Jul 10, 2002 8:53 pm

  • Quote

Post by carambola5 » Wed Oct 23, 2002 6:14 am

I definitely do not claim to be a proficient bash programmer. But hey, it works. I call it 'remote':

Code: Select all

#!/bin/bash
SERVERS="CAE CS Quit"
ENGR="cae.my_u.edu"
COMPSCI="cs.my_u.edu"
if [ -z "$1" ]; then
	select serv in $SERVERS; do
		if [ "$serv" = "CAE" ]; then
			ssh $ENGR
			exit
		elif [ "$serv" = "CS" ]; then
			ssh $COMPSCI
			exit
		elif [ "$serv" = "Quit" ]; then
			exit
		else
			echo bad option
			echo 
		fi
	done
else
	if [ "$1" = "cae" ]; then
		ssh $ENGR
	elif [ "$1" = "cs" ]; then
		ssh $COMPSCI
	else
		echo Bad argument.  Servers are cs or cae
		echo eg:  remote cae
	fi
fi
Top
carambola5
Apprentice
Apprentice
User avatar
Posts: 214
Joined: Wed Jul 10, 2002 8:53 pm

  • Quote

Post by carambola5 » Tue Jan 14, 2003 9:52 pm

screenie:

Code: Select all

#!/bin/bash
PICPATH=$HOME/pictures/screenshots
INDEX=`cat $PICPATH/index.dat`
import -window root $PICPATH/ss$INDEX.png
echo $(($INDEX + 1)) > $PICPATH/index.dat
I mapped this to my printscreen key through .fluxbox/keys
Top
H-Pi
Apprentice
Apprentice
User avatar
Posts: 175
Joined: Wed Jun 26, 2002 8:52 pm
Location: Delft (NL)
Contact:
Contact H-Pi
Website

  • Quote

Post by H-Pi » Tue Jan 14, 2003 10:30 pm

nice thread!

Code: Select all

alias es='emerge -s'
alias ep='emerge -p'
alias ue='ACCEPT_KEYWORDS="~x86" emerge'
Ihated to type ACCEPT_KEYWORDS="~x86, and didn't want to put it in my make.conf so made an alias for it, and then thought: why not es and ep too?
I find it remarkable how many people don't use the history command.
I just use the tab, page-up and page-down buttons, they take away the need of an 'history'
Last edited by H-Pi on Tue Jan 14, 2003 10:52 pm, edited 2 times in total.
Top
red_over_blue
Guru
Guru
User avatar
Posts: 310
Joined: Mon Dec 16, 2002 6:46 pm

  • Quote

Post by red_over_blue » Tue Jan 14, 2003 10:46 pm

Code: Select all

alias recal='history | grep'
You can then just type

Code: Select all

!955
Supposing 955 was the line you wanted to execute again. I also like using ctrl-l for clear (screen) and ctrl-d to log-out.
Top
sa
Guru
Guru
User avatar
Posts: 450
Joined: Mon Jun 10, 2002 7:21 pm

  • Quote

Post by sa » Wed Jan 15, 2003 1:06 am

Code: Select all

alias play-dvd='xine --auto-play -s dvd'
xnest='Xnest -auth .Xauthority_blah -full -sync -name "Xnest :1" -fp `xset -q | grep fonts` :1'
:-)
Top
frew
n00b
n00b
Posts: 29
Joined: Tue Nov 12, 2002 12:25 am

  • Quote

Post by frew » Wed Jan 15, 2003 1:32 am

Wow, history really is useful...Can't beleive I've never seen it before.

I know this is useless but I like it: (btw, you have to emerge cowsay first)

Code: Select all

date +%l:%M| cowsay
I can't think of anything else at the moment...

Oh yeah, and put that in the begginging of .bashrc
Top
zojas
Veteran
Veteran
User avatar
Posts: 1136
Joined: Mon Apr 22, 2002 11:29 pm
Location: Phoenix, AZ
Contact:
Contact zojas
Website

  • Quote

Post by zojas » Wed Jan 15, 2003 7:32 am

I use history substitution a lot. not only '!!' to repeat the last command, !23 to repeat command number 23, and !c to repeat the last command which started with 'c', but you can also use '!$' to get the last word from the previous command. so say you wanted to check for a package in the mask file, then edit it:

Code: Select all

grep kde /usr/portage/profiles/package.mask
vim +/kde !$
before I started using etc-update I used to do this a lot:

Code: Select all

diff net.eth0 ._cfg000.net.eth0
mv !$ !^
(!^ means the first argument of the previous command)

also !* means all the arguments from the previous command (without the program name)

Code: Select all

diff net.eth0 ._cfg000.net.eth0
vim -o !*
also I make an alias called 'h' for the word 'history'
Top
Empty_One
n00b
n00b
User avatar
Posts: 32
Joined: Fri Oct 18, 2002 1:40 pm

  • Quote

Post by Empty_One » Wed Jan 15, 2003 3:44 pm

dumb question, but how is the hisory better than just cycling through the list with the up arrow? Seems like you would have to read thru the list anyway
"Barney sucks! Best Buy sucks! Sony Sucks! Microsoft sucks, Bill Gates is the anti-Christ and John Ashcroft can kiss my ass!" Wil Wheaton
Top
zojas
Veteran
Veteran
User avatar
Posts: 1136
Joined: Mon Apr 22, 2002 11:29 pm
Location: Phoenix, AZ
Contact:
Contact zojas
Website

  • Quote

Post by zojas » Wed Jan 15, 2003 4:03 pm

with history you see it all at once. the eye travels faster than the fingers! try it, once you do it a few times you'll see.
Top
Post Reply

376 posts
  • Page 1 of 16
    • Jump to page:
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 16
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic