LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 11-07-2018, 04:36 AM   #1
subincb
LQ Newbie
 
Registered: Nov 2018
Posts: 1

Rep: Reputation: Disabled
alias


How can I create an aliasing command for finding regular user names in my machine.

Last edited by subincb; 11-07-2018 at 04:37 AM.
 
Old 11-07-2018, 04:40 AM   #2
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 900

Rep: Reputation: 290Reputation: 290Reputation: 290
Have you done some research on the internet already?
 
Old 11-07-2018, 04:47 AM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,627

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Quote:
Originally Posted by subincb View Post
How can I create an aliasing command for finding regular user names in my machine.
The answer to your question is: "You can do that several ways.". I prefer to do it in a script, because I find filtering out non-privileged accounts easier that way, but it has been done as an alias before. I suggest a search at duckduckgo or google.

One thing to look for is a command that already exists to do that job. There is seldom a good reason to "reinvent the horse".

Last edited by wpeckham; 11-07-2018 at 04:49 AM.
 
Old 11-07-2018, 04:47 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Local users are stored in /etc/passwd. This file consists of one line per user; each line has fields that are separated with a colon. The first field contains the user name, the third field is the user ID.

I am not quite sure what a "regular user" is. I would say any user except root. root has user ID 0.
So, get all lines that have a value different than zero in the third field, and print their first field. Personally, I would use awk for this. A combination of grep and cut should also cut it (pun intended).

The next question I have: What is an "aliasing command"? The shell has a command "alias" which allows creating a name for a string. For example:
Code:
alias lsf="ls -F"
creates an alias named lsf. Whenever you type lsf, the command ls -F is executed.

So I guess you have to create an alias in the following way:
Code:
alias allmyusers="my awk command"

Last edited by berndbausch; 11-07-2018 at 04:50 AM.
 
Old 11-08-2018, 06:55 AM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Linux List All Users In The System
 
  


Reply



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
Bash: how to avoid a command inside an alias being used as another alias? dedec0 Linux - Newbie 25 12-11-2017 10:20 AM
bash script to display alias commands and un-alias any less than 12 characters bani Linux - Newbie 5 01-19-2014 12:34 PM
LXer: alias.sh puts your Linux shell alias on the clouds LXer Syndicated Linux News 0 01-21-2013 12:00 AM
Wildcard email alias in /etc/alias file custangro Linux - Enterprise 1 10-02-2009 12:17 PM
Alias question (2 commands for one alias) gflores Linux - Newbie 3 01-21-2006 12:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:51 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