LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-08-2012, 12:34 AM   #1
nblab
LQ Newbie
 
Registered: Jul 2012
Posts: 4
Blog Entries: 1

Rep: Reputation: Disabled
creating alias for normal users


hi,

i need to create an alias of a command named
find_c="find . -path '*.c'|wc -l"

and i wanted that every user should be able to execute this alias when ever they login and wish to execute.

OR

it would be better if this executes each time a user login.
 
Old 10-08-2012, 12:52 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Quote:
Originally Posted by nblab View Post
hi,

i need to create an alias of a command named
find_c="find . -path '*.c'|wc -l"

and i wanted that every user should be able to execute this alias when ever they login and wish to execute
I'm not sure about aliases since I never use them. Using functions is possible as well. I would suggest using a script though and place it in /usr/local/bin. e.g. /usr/local/bin/find_c
Code:
#!/bin/bash
exec find . -path '*.c' | wc -l
Afterwards change the permission of the file to 0755.
Quote:
it would be better if this executes each time a user login.
Do you mean creating the alias? But that's not necessary if you already have a script. Anyhow you could use .bashrc for that, or /etc/profile for general startup.

Of course some people would recommended/criticize how one should manipulate those files; it also depends on your system or distro, but those are the basics.
 
1 members found this post helpful.
Old 10-08-2012, 01:40 AM   #3
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by nblab View Post
hi,

i need to create an alias of a command named
find_c="find . -path '*.c'|wc -l"

and i wanted that every user should be able to execute this alias when ever they login and wish to execute.

OR

it would be better if this executes each time a user login.
why would you want to execute a alias everyime?
It is something you set once and put it in the .bash_profile file of the user you want to set so everytime the user will log in the alias will be applied to him/her
 
1 members found this post helpful.
  


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
[SOLVED] I need help with creating a certain alias please help, thanks... BMan8577 Linux - Newbie 3 04-29-2011 08:56 PM
creating alias kaplan71 Debian 2 03-20-2008 01:14 PM
trouble creating alias coldbeerz Linux - Newbie 4 11-19-2007 11:37 AM
Creating Command Alias? carlosinfl Linux - General 3 07-14-2007 06:32 PM
Need advice on creating an alias thorney Linux - General 2 11-27-2005 08:33 PM


All times are GMT -5. The time now is 10:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration