Skip to content

Instantly share code, notes, and snippets.

@JohnRTitor
Last active April 3, 2024 18:18
Show Gist options
  • Save JohnRTitor/2cc4f9185a14b8a161303cee873110eb to your computer and use it in GitHub Desktop.
Save JohnRTitor/2cc4f9185a14b8a161303cee873110eb to your computer and use it in GitHub Desktop.
Linux Tips and Tricks

Home directory and env vars not set properly in su (switch user)

Use a login shell mode instead, it will initiate the client user's profile and rc scripts. It also prevents the client user shell from inheriting host env vars.

su -l example-user

Capture text from stderr

cat command using pipe | can only capture data from stdout.

Use this to capture data from stderr as well. Here less is used as pipe destination.

your_command 2>&1 | less

Rest....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment