Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sg(1) [v7 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)

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

12 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

newgrp command

I'd like to make an alias of commands which contains the command newgrp. exple: alias my_cmde newgrp toto; my_pg & this line doesn't work. why ? Thanks for your help (2 Replies)
Discussion started by: Nathe
2 Replies

2. 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

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. 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

5. 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

6. 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

7. Shell Programming and Scripting

automatically change owner and group

We have a program that when a new account is created using the webpage it creates a new directory on the linux filesystem for the account. The problem is the process that creates the directory is as root user, as I want ftpuser to be able to login I have to manually login and chown -R the... (1 Reply)
Discussion started by: borderblaster
1 Replies

8. Solaris

Creating User account with limited permission

Hi All, I want to create an user account which can only excute "df -kh" and "prstat -a" command. The user will not be able to perform "rm" and other critical commands. Is there a way to do it? rgds, Ronny (2 Replies)
Discussion started by: ronny_nch
2 Replies

9. Shell Programming and Scripting

Automating 'newgrp' command - how?

Hi, I have to add the 'newgrp' command to my login (.cshrc) script. The problem is that if I add it, it comes to infinite look, since newgrp opens new shell again and again. How to automate the newgrp when I have to login, and avoid that loop? Currently I'm thinking of a condition that... (2 Replies)
Discussion started by: moshmosh
2 Replies

10. Shell Programming and Scripting

smart search through find command

The requirement here is i'm searching for a particular word from the log file between two time stamp. The process for particular account will happen, so i need to see there is any error occurred in between before it completes. in the below code yyyyy and xxxxx are two unique fields. initially... (1 Reply)
Discussion started by: Amutha
1 Replies

11. UNIX for Dummies Questions & Answers

Sed command

on “sed” command EmpData(Sample Database) 1122|j.b. saxena |g.m. |account |12/12/52|6000 2233|n.k. gupta |d.g.m |sales |31/12/40|9000 4545|anil agarwal |director |account |06/07/47|7500 5656|lalit choudhury |executive|marketing|07/09/50|5000 1265|chanchal singhvi|g.m. |admin |12/09/63|6000... (1 Reply)
Discussion started by: tp2115
1 Replies

12. 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