About
Community
Bad Ideas
Drugs
Ego
Erotica
Fringe
Society
Technology
register | bbs | search | rss | faq | about
meet up | add to del.icio.us | digg it
Go Back   Community > Technology > Everything *NIX
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Everything *NIX This is a general forum about all forms of *nix. Post your ideas and thoughts on this wonderful OS family. Talk about your personal favorite flavor of *nix and why you think it's so much better than the others. Anything pertaining to *nix and *nix administration should be posted here.

Reply
 
Thread Tools Display Modes
  #1   Add login to your ignore list  
Old 2007-04-02, 00:10
login login is offline
 
Canada login is an unknown
Default Useful bash features :)

Here's a guide for newbies on how to customize bash.

- You can set you're terminal in emacs/vi mode, which means you will have emacs/vi controls in when typing commands

"set -o vi/emacs"

- You can set aliases in .bashrc

"alias test='ls -all'" now test is equal to ls -all

- You can also edit /etc/profile and type any program you would like to execute on bash startup.

- You can modify the PS1 variable in .bashrc, which is resposible for the

[hostname@domain dir]$

Here is an example of my PS1:

PS1='\[\033[1m\]\[\033[40m\]\[\033[31m\][\[\033[30m\]\[\033[49m\]\u@nix.net \[\033[37m \]\[\033[3 m\]\w\[\03 3[23m\]\[\ 033[40m\]\ [\033[31m\ ]]\[\033[3 6m\]\[\033 [40m\]$\[\033[33m\]\[\033[49m\] \[\033[40m\]'

For further explanations on PS1 see:

http://tinyurl.com/hmgn4





[This message has been edited by login (edited 04-02-2007).]
Reply With Quote
  #2   Add jsaxton14 to your ignore list  
Old 2007-04-02, 00:17
jsaxton14 jsaxton14 is offline
Regular
 
Minneapolis, MN, USA Send a message via AIM to jsaxton14 Send a message via MSN to jsaxton14 jsaxton14 is an unknown
Default

Here's a cool trick I learned the other day:

john@lenin:/data/test$ ls -al

total 8

drwxr-xr-x 2 john john 4096 2007-04-01 19:14 .

drwxr-xr-x 19 john root 4096 2007-04-01 19:13 ..

-rw-r--r-- 1 john john 0 2007-04-01 19:14 foo

john@lenin:/data/test$ !ls

ls -al

total 8

drwxr-xr-x 2 john john 4096 2007-04-01 19:14 .

drwxr-xr-x 19 john root 4096 2007-04-01 19:13 ..

-rw-r--r-- 1 john john 0 2007-04-01 19:14 foo

john@lenin:/data/test$

Basically, if you type !command, command is called with the same arguments that were used the last time you used said command. This is quite useful with commands such as ssh, for example.
Reply With Quote
  #3   Add BiOPSY to your ignore list  
Old 2007-04-02, 01:29
BiOPSY BiOPSY is offline
Moderator
 
Ft. Payne, Alabama BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to
Default

Quote:
quote:Originally posted by login:



- You can also edit /etc/profile and type any program you would like to execute on bash startup.

This is probably better done using ~/.bash_profile

Also, ~/.bashrc is BASH Run Control, where you would execute startup commands when the shell is invoked for your user, rather than ~/.bash_profile, where you would set say, environment variables or such and export them. It doesn't make a big difference where you do these things depending on the nature of what it is you are trying to accomplish, but I just wanted to clarify that.

For example, I set several variables within ~/.bash_profile for my user which are CVS_RSH and CVSROOT since I connect to the Fedora CVS development server to checkout CVS trees.

It beats having to export these variables everytime I login.
Reply With Quote
  #4   Add login to your ignore list  
Old 2007-04-02, 02:26
login login is offline
 
Canada login is an unknown
Default

Quote:
quote:Originally posted by BiOPSY:

This is probably better done using ~/.bash_profile

Also, ~/.bashrc is BASH Run Control, where you would execute startup commands when the shell is invoked for your user, rather than ~/.bash_profile, where you would set say, environment variables or such and export them. It doesn't make a big difference where you do these things depending on the nature of what it is you are trying to accomplish
I thought setting variables in .bash_profile was a security risk.

May be i'm wrong though.
Reply With Quote
  #5   Add BiOPSY to your ignore list  
Old 2007-04-02, 03:24
BiOPSY BiOPSY is offline
Moderator
 
Ft. Payne, Alabama BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to
Default

Quote:
quote:Originally posted by login:

I thought setting variables in .bash_profile was a security risk.

Do you have some document pertaining to this?

I'm not sure how it could be a security risk.
Reply With Quote
  #6   Add login to your ignore list  
Old 2007-04-02, 03:51
login login is offline
 
Canada login is an unknown
Default

Quote:
quote:Originally posted by BiOPSY:

Do you have some document pertaining to this?

I'm not sure how it could be a security risk.
If someone managed to get access to you're account and you su to root. You use a variable you've settup in you're local .bash_profile

But the hacker has changed it to point to some malicious code.

I'm not sure if you can still use that variable once you've su'ed.

[This message has been edited by login (edited 04-02-2007).]
Reply With Quote
  #7   Add BiOPSY to your ignore list  
Old 2007-04-02, 04:29
BiOPSY BiOPSY is offline
Moderator
 
Ft. Payne, Alabama BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to
Default

Quote:
quote:Originally posted by login:

If someone managed to get access to you're account and you su to root. You use a variable you've settup in you're local .bash_profile

But the hacker has changed it to point to some malicious code.

I'm not sure if you can still use that variable once you've su'ed.

Using su without --login will still retain the environment variables from your user's shell, this is true, now what "malicious code" are you talking about setting a variable to?
Reply With Quote
  #8   Add login to your ignore list  
Old 2007-04-02, 04:40
login login is offline
 
Canada login is an unknown
Default

Quote:
quote:Originally posted by BiOPSY:

Using su without --login will still retain the environment variables from your user's shell, this is true, now what "malicious code" are you talking about setting a variable to?
Example:

Setting the SHELL to /home/username/similartobashwithmaliciouscode

Reply With Quote
  #9   Add BiOPSY to your ignore list  
Old 2007-04-02, 05:04
BiOPSY BiOPSY is offline
Moderator
 
Ft. Payne, Alabama BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to BiOPSY is worth listening to
Default

Quote:
quote:Originally posted by login:

Example:

Setting the SHELL to /home/username/similartobashwithmaliciouscode
Dude, your shell is specified in /etc/passwd not via the $SHELL environment variable.
Reply With Quote
  #10   Add login to your ignore list  
Old 2007-04-02, 05:21
login login is offline
 
Canada login is an unknown
Default

I must be very bored.

I also forgot about /etc/shells.

Anyway, that was just an example.
Reply With Quote
This thread continued for 2 pages in the real archive, 15 posts total - only page 1 survived here.
Reply


Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes
Linear Mode Linear Mode
Hybrid Mode Switch to Hybrid Mode
Threaded Mode Switch to Threaded Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

 
To the best of our knowledge, the text on this page may be freely reproduced and distributed.
 

totse.com certificate signatures
 
 
About | Community | Bad Ideas | Drugs | Ego | Erotica | Fringe | Society | Technology
Hot Topics