Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am looking for some code to get the linux username.. I have come across code to get current username but what I need to get is the username that was used when installing linux..
For example, if im logged in as root user, how can i get the initial username that was used when installing ubuntu?
Better still, Is there a variable that I can put in my script that will search & store install username..
you can use fact, that default uid and gid for first created user is 1000:
grep 1000:1000: /etc/passwd|cut -f1 -d':'
but keep in mind:
when default user was deleted, you get empty string
if it running on non standard configuration, uid, and gid may be different
this is not good practise (see next point)
you ate not considering multi-seat configurations, when station have many users, you should provide user config file, where user can put usernames he wants to processed or do it from command line
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 months ago.
Improve this question
I have registered some linux machines intro AD with sssd and it works great, but I have an issue with the bash prompt. Some AD usernames start with $ and the prompt refuses to display it, so now I'm left with the string similar to #servername:~$
If I do an export PS1="\$USER#\H" it gets displayed correctly.
Any ideas on how to make bash prompt either escape the special character, or make sssd edit the bashrc with the "correct" format?
This is more of a Linux configuration question and would work better in unix.stackexchange.com or askubuntu, but generally to change default user configuration you'd want to edit the files in /etc/skel.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I have created a new user on a CentOS server. I don't know why, but when I connect with this new user the current path is not showing in the terminal. Instead, I can see '-bash-4.2'. What is the meaning of -bash-4.2 and how can I display the current path (such as /home)?
Your current prompt variable ($PS1) contains something like \s-\v\$ which corresponds to the name of the shell and its version. To have the prompt display the current path (along with the trailing $ you currently have), set PS1 with this:
PS1='$PWD\$ '
Using either of \w or \W will produce similar results, except for your home directory.
To keep this setting going forward, you'll want to set that value in your ~/.bashrc file.
See more options in the bash manual under PROMPTING or online at https://www.gnu.org/savannah-checkouts/gnu/bash/manual/html_node/Controlling-the-Prompt.html#Controlling-the-Prompt
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have requirement to check members of the group "wheel" periodically.
I see that 'members wheel' is expected to display the members of that group. However when i tried, it says command not found. I see no entries in the man page as well.
I am using RHEL - Linux Version 3.10 (Red Hat 4.8.5)
I know we can use awk and cat in combination to get these details from "/etc/group" file
But is there a straight forward or a better approach?
This is an answered question from Linux admin.
In short the answer is:
I prefer to use the getent command ...
Since getent uses the same name service as the system, getent will show all information, including that gained from network information sources such as LDAP.
So for a group, you should use the following ...
getent group name_of_group
where name_of_group is replaced with the group you want to look up.
Note that this only returns supplementary group memberships, it
doesn't include the users who have this group as their primary group.
There are a whole lot of other lookups that you can do ... passwd
being another useful one, which you'll need to list primary groups.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a server in which there are 2 users: root and bob while I am logged in as root, everything look normal. Files are colored according to type, I can press up and down to search for previous typed commands, and I can see the current folder name in the shell prompt.
Being logged in as user bob everything seems "weird", nothing is colored, pressing up and down give me weird characters in the command line like "^[[A^[[B" and I can only see the character "$" in the command line prompt.
Is there a way to fix the issue?
Two possible features could be causing this.
The first: your two users could be using different terminals (i.e. bash, busybox, etc.)
You can change this per user in the /etc/passwd file
The second comes down to preferences, typically stored in ~/.profile, ~/.bash_rc and ~/.bash_profile. ("~" refers to the home directory for that user, also found in /etc/passwd file, typically "/home/USERNAME").
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
this is my first question here.
I'm using a Centos server.
I want to know how to permit proprely a non-sudoer user (let's call it Bob) to read a specific file in /var/log. I want to be able to read some logs without being root and without jeoparadizing my logfile.
For the moment,
I created a group named "loggers"
I added Bob to the group
I made a chgrp for the file I want to read with Bob
I changed file permissions from 600 to 640.
Is there any better (secure) way to make the same thing ?
If you're happy with a special group, then that is the way to do it. The alternative is to use ACLs, which are additive to standard unix permissions. You'd return your logfile to its original unix permissions then permit Bob with something like
setfacl -m user:Bob:r-- /var/log/mylogfile.log
There are circumstances where ACLs are unfavorable, in particular where you have file backup/migration across servers or filesystems. However, this isn't the case for your scenario.