Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sg(1) [centos man page]

SG(1)								   User Commands							     SG(1)

NAME
sg - execute command as different group ID SYNOPSIS
sg [-] [group [-c ] command] DESCRIPTION
The sg command works similar to newgrp but accepts a command. The command will be executed with the /bin/sh shell. With most shells you may run sg from, you need to enclose multi-word commands in quotes. Another difference between newgrp and sg is that some shells treat newgrp specially, replacing themselves with a new instance of a shell that newgrp creates. This doesn't happen with sg, so upon exit from a sg command you are returned to your previous group ID. CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool: SYSLOG_SG_ENAB (boolean) Enable "syslog" logging of sg activity. FILES
/etc/passwd User account information. /etc/shadow Secure user account information. /etc/group Group account information. /etc/gshadow Secure group account information. SEE ALSO
id(1), login(1), newgrp(1), su(1), gpasswd(1), group(5), gshadow(5). shadow-utils 4.1.5.1 05/25/2012 SG(1)

Check Out this Related Man Page

SG(1)                                                              User Commands                                                             SG(1)

NAME
sg - execute command as different group ID SYNOPSIS
sg [-] [group [-c ] command] DESCRIPTION
The sg command works similar to newgrp but accepts a command. The command will be executed with the /bin/sh shell. With most shells you may run sg from, you need to enclose multi-word commands in quotes. Another difference between newgrp and sg is that some shells treat newgrp specially, replacing themselves with a new instance of a shell that newgrp creates. This doesn't happen with sg, so upon exit from a sg command you are returned to your previous group ID. CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool: SYSLOG_SG_ENAB (boolean) Enable "syslog" logging of sg activity. FILES
/etc/passwd User account information. /etc/shadow Secure user account information. /etc/group Group account information. /etc/gshadow Secure group account information. SEE ALSO
id(1), login(1), newgrp(1), su(1), gpasswd(1), group(5), gshadow(5). shadow-utils 4.5 01/25/2018 SG(1)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

newgrp in a script

I want to do these commands in a script: if the user name is 'toto' then the user switch to the group toto_group and then 2 others scripts are launched. Unfortunately, after the command 'newgrp' the 2 scripts are not launched correctly. But if I do the same, by hand, one line per one line, it... (11 Replies)
Discussion started by: Nathe
11 Replies

2. UNIX for Advanced & Expert Users

Changing the way "more" works

Hi, The "more" command is currently being used to display reports to users. However, "more" allows the user to shell out to the command prompt if they happen to type in "!" and they can also start editing the file if they type in "v". Is it possible to restrict users access to these by... (4 Replies)
Discussion started by: barkerj
4 Replies

3. Shell Programming and Scripting

Need help with the syntax using awk+grep

Hi, I need to extract information from a 4 GB file based on the following conditions: 1) Check for the presence of a set of account numbers Each account number is present along with other information within a PAGESTART and PAGEEND. The file looks like this: PAGESTART ACCOUNT NO 123... (6 Replies)
Discussion started by: kthri
6 Replies

4. UNIX for Advanced & Expert Users

Unix Doubt

What is Primary Group & Secondary group and what is the difference between them. (5 Replies)
Discussion started by: harishankar
5 Replies

5. Shell Programming and Scripting

Shellscript to Sudo other account

Hi, I have to write a shell script to sudo other account. Foreg, i am working in account ramdev1, i have a sudo access where through shell script i need to sudo another account ramdev2 and read a file "ram.inc" get those data and save it in a .txt file and return it? Since i am new to... (21 Replies)
Discussion started by: sachin.tendulka
21 Replies

6. Shell Programming and Scripting

while loop issues

Hi guys, Been sifting through these forums for awhile, but never had an account or needed to post. Shoutouts to a great forum with heaps of useful info. Now i consider myself a noob when it comes to linux and to bash scripting. I recently started to learn to use Vmware ESX server which uses... (4 Replies)
Discussion started by: ryath
4 Replies

7. HP-UX

Previous command

Hi, i would like to retrieve (only retrieve, not execute) a previous command which i executed on the command prompt. I tried the 'up arrow' key, but its not working. Instead,it showed me some funny characters. I searched around and i found the way to do it was using the way below. Several... (5 Replies)
Discussion started by: new2ss
5 Replies

8. Shell Programming and Scripting

Join, GREP

Hi All, I have 2 file. ACC_NUM contains only account numbers & ACC_DETAIL contains all information including account number seperated by ~ delimiter. i am serching the account number in ACC_DETAIL from ACC_NUM. If it is exist, then copy all information in ACC_DETAIL_NEW file. For that i... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

9. UNIX for Dummies Questions & Answers

Default Group

How do I set the default group a new user account belongs to? Thanks (3 Replies)
Discussion started by: mojoman
3 Replies

10. Shell Programming and Scripting

Need to find Unique not used Number

Wrote a script to create a hidden account in OS X. It works perfect but I need to check if the UID is already in use before I tried to create the account. dscl . list /Users UniqueID | awk '{print $2}' | while read UIDS do if ; then echo "UID Is Already in USE" i=`expr "$2" - 1` echo... (4 Replies)
Discussion started by: elbombillo
4 Replies

11. Shell Programming and Scripting

Understanding Logic and Flow better

i am in an epic quagmire of horrid misunderstanding. its been a while since ive been in the scene, couldnt remember my login for the account i used to have here, so excuse the 1st post. i dont want it to seem like ima post n boogy. in any case here we go: just recently installed mandriva... (6 Replies)
Discussion started by: SirDonkeyPunch
6 Replies

12. Shell Programming and Scripting

command to group records

hi, i have records like this supplier,product, persons involved 10,150,ravi@yahoo.com 30,200,ravi@yahoo.com 20,111,payal@gmail.com 40,211,ravi@yahoo.com i want to write a command which displays values like this 10,30,40,ravi@yahoo.com for ravi@yahoo.com if there are n number of... (7 Replies)
Discussion started by: trichyselva
7 Replies

13. Shell Programming and Scripting

Unique account id file

I have a fixed length file (each record of 288 characters). The unique id in each record is account_id which is from position 1:30 My file is having duplicate account ids ( records having same account id). However the information except account_id can be different. ( Most of the records... (5 Replies)
Discussion started by: varunrbs
5 Replies

14. Shell Programming and Scripting

User Logging

Hi, I have several engineers logging into servers with the same system username and passwords eg root. I was thinking about adding a script to bashrc where a user is forced upon login to enter their name and once that has executed there history is logged/redirected to a log file somewhere. I... (10 Replies)
Discussion started by: maxwellhouse
10 Replies

15. Solaris

Newgrp fails on only 1 group

I have a handful of users who can't 'newgrp' to one specific group from Solaris 9 and 10 nodes and always get this prompt: newgrp: Password: We never get prompted by 20+ other groups and this group never prompts for a password from Red Hat Linux nodes. Authentication comes from AD and there's... (4 Replies)
Discussion started by: rnae20
4 Replies