•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

What does su mean?

  • Home
  • Client
  • Qa Forum
  • What does su mean?

Posted By: Danny | 1 Replies | Last Reply On: Jun 25, 2021 11:37:49

I am still new to Linux operating system and trying my hands on the command line. I have come across the 'su', but I don't know its usage. 

Psychz - Harish

Votes: 0Posted On: Jun 25, 2021 11:37:49
 

The 'su' is short for substitute user or commonly known as switch user utility that allows you to run commands with another user’s privileges.  When executed it invokes a shell without changing the current working directory or the user environment. When the command is used without specifying the new user id as a command line argument, it defaults to using the root of the system.

Using su is the simplest way to switch to the administrative account in the current login session. This is especially handy when the root user is not allowed to log in to the system through ssh or using the GUI display manager. When run from the command line, su asks for the target user's password, and if authenticated, grants the operator access to that account and the files and directories that account is permitted to access.

Let us see how to use the su command. The general syntax for the su command is as follows:

# su [options] [-] [ [...]]

Following are some of the Options that you can use with the command

 -m, -p, --preserve-environment  do not reset environment variables 
-g, --group              specify the primary group
-G, --supp-group         specify a supplemental group
-, -l, --login                  make the shell a login shell
-c, --command          pass a single command to the shell with -c
--session-command      pass a single command to the shell with -c and do not create a new session
-f, --fast                      pass -f to the shell (for csh or tcsh)
-s, --shell              run if /etc/shells allows it
-P, --pty                       create a new pseudo-terminal
-h, --help                      display this help
-V, --version                   display version

Note: When invoked without any option, the default behavior of su is to run an interactive shell as root:

 

Use a Different User in the Same Environment

You can keep the environment of the current user account with the –p ( -P, --pty create a new pseudo-terminal)

# su –p [user]

Replace [user] with the actual username you want to switch to.

Example

jack@localhost:~$ su -p jones
Password:

jones@localhost:~$ echo $home
/home/jack


The user account will switch, but you’ll keep the same home directory. This is useful if you need to run a command as a different user, but you need access to the current user’s data.

 

Use a Different Shell

To use a different shell, or operating environment, enter the following:

# su –s /usr/bin/sh

This command opens a root user account in shell.

 

su is a command that allows you to temporarily become another user and execute commands as a substitute user. We hope that you find this response useful. Please feel free to leave a comment and leave us a up vote.

Was this reply helpful?

Related topics

  • what does hipaa stand for
  • What Does NTP Mean?
  • Unlimited Dedicated Server Hosting In Europe
  • Do you sell hardware for Colocation?
  • Dedicated Servers In US
  • Learn About Colocation Benefits And How To Get Started
  • What is DDoS and How to Protect Against a DDoS Attack
  • What is The 95th Percentile Bandwidth Metering?
  • How to setup a dedicated server for Minecraft Bedrock
  • Regex: regular expression cheat sheet
  • The Future of Dedicated Servers: Trends and Predictions
  • Why Gaming Companies are Choosing Bare Metal Servers
  • In Comparison: SQL VS NoSql
  • CDN Hosting and why Every website should utilize a CDN
  • All You Need To Know About Cloud Deployment Models
Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2023 Psychz Networks, A Profuse Solutions Inc Company