LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-11-2006, 08:38 AM   #1
UFCfighter
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Rep: Reputation: 0
Unhappy Command Aliases???


Does anyone know where command aliases in SLACKWARE go? Using the alias command, aliases are gone after logout. Where do global aliases vs. user aliases placed? I would appreciate the help, thanks.
 
Old 07-11-2006, 08:46 AM   #2
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
Local aliases should be placed in ~/.bashrc and global ones in /etc/bashrc

- Piete
 
Old 07-11-2006, 08:48 AM   #3
UFCfighter
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks, but...

Thanks for the reply, but I don't have a .bashrc in my entire system. Is this something that I can just create, or could aliases be placed elsewhere? Thanks.
 
Old 07-11-2006, 08:54 AM   #4
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
You should just be able to create one and have it working, bash is very easy going =)
 
Old 07-11-2006, 08:56 AM   #5
binary_y2k2
Member
 
Registered: Jul 2005
Location: England, UK
Distribution: Ubuntu 8.04 Server, Kubuntu 12.04
Posts: 698
Blog Entries: 1

Rep: Reputation: 31
If your login shell is bash you should have it in your home dir and a system one in /etc (maybe called bash.bashrc) if not loon in /etc/profile
 
Old 07-11-2006, 08:57 AM   #6
UFCfighter
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
I created .bashrc but...

I created the files in a few places to try it out. First, I created etc/.bashrc. Then I tried home/user/.bashrc, usr/.bashrc, and a few other places. None of them worked.
 
Old 07-11-2006, 09:02 AM   #7
UFCfighter
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
etc/profile

Thanks for the help. There is a file etc/profile, and I tried adding ALIAS XX="XX -X", but it didn't work. I also tried xx = "xx -x" but still didn't work.
 
Old 07-11-2006, 09:04 AM   #8
binary_y2k2
Member
 
Registered: Jul 2005
Location: England, UK
Distribution: Ubuntu 8.04 Server, Kubuntu 12.04
Posts: 698
Blog Entries: 1

Rep: Reputation: 31
in the /etc dir the file is called either /etc/bashrc (no leading dot) or /etc/bash.bashrc

What is the cpntense of your /etc/profile file?
 
Old 07-11-2006, 09:16 AM   #9
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
Ahh, I see, we still have some problems.

Basically ya gotta set up the system ...

The system is as follows:

/etc/profile --> $HOME/.bash_profile --> $HOME/.bashrc --> /etc/bashrc

If you don't already have $HOME/.bash_profile, then create it and make sure it contains the following:

Code:
# Source local bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
Then, in $HOME/.bashrc make sure the following exists:

Code:
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
This will preserve your aliases when you su from user, and allow alises to crop up when you use an xterm.

I realise it's not exceptionally clear, but the explanation is long and i'm tired =)
- Piete.
 
Old 07-11-2006, 09:18 AM   #10
UFCfighter
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
no bashrc, .bashrc, bash, .bash, etc...

no bashrc, .bashrc, bash, .bash, etc...
 
Old 07-11-2006, 09:22 AM   #11
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You probably aren't using bash. When you type at a commandline

echo $SHELL

what do you see?

If you are using csh or tcsh, then your shell startup script is .cshrc
You can add aliases there.

eg.
alias dir 'ls -lash'

(Note different syntax from Bourne shells.)

--- rod.
 
Old 07-11-2006, 09:24 AM   #12
sbabaro
LQ Newbie
 
Registered: Dec 2003
Posts: 7

Rep: Reputation: 0
/etc/profile.d

I have aliases working with bash with an executable file that I called aliases.sh in /etc/profile.d dir
then you need to be sure that your aliases will be loaded anyway, either if your shell is a login one or not.
To solve this I create .bashrc in my home
[code]


[ -f /etc/profile ] && . /etc/profile
[ -f /etc/bashrc ] && . /etc/bashrc

[\code]

It executes the files in /etc/profile.d, loading also your aliases
 
Old 07-11-2006, 09:51 AM   #13
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
Quote:
no bashrc, .bashrc, bash, .bash, etc...
You can make them, there is no problem doing that. If you don't have the file ... write it.

I like sbabaro's solution to aliases - very neat, very Slackware.
 
Old 07-11-2006, 09:59 AM   #14
UFCfighter
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
I'm definitely using bash

I'm using bash, but I don't have the files that people say I should have. This was a straight install of Slackware 10.2.
 
Old 07-11-2006, 10:19 AM   #15
sbabaro
LQ Newbie
 
Registered: Dec 2003
Posts: 7

Rep: Reputation: 0
create it!

as piete said, create it!

The only files that you have in a fresh Slack is /etc/profile and /etc/profile.d (with several scripts inside)
The others you need to create by yourself
Use your favorite editor and write it down the file using one of the solution shown in this thread
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sendmail and NIS databases (aliases, mail.aliases) - what kind of databases? cotton213 Linux - Software 0 03-14-2006 05:57 PM
Aliases SkyeFyre Fedora 8 03-18-2005 07:35 PM
Permanent Command Aliases - Slackware 9.1 erraticassassin Slackware 3 01-09-2005 03:08 PM
making aliases via command line MACSRULE *BSD 1 04-07-2004 03:14 PM
what aliases do you use most? m0rl0ck Linux - General 17 02-12-2003 01:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration