From 2d048a9a738dde0e957338f928490da491894b86 Mon Sep 17 00:00:00 2001 From: Not Mark Date: Mon, 22 Aug 2016 16:50:22 -0500 Subject: [PATCH 1/5] Update README.md - Added bash _quick substitution_ - Added some improvements to the bullet on `sudo` --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a3990e..3e32d5c 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,11 @@ Notes: cat hosts | xargs -I{} ssh root@{} hostname ``` +- To rerun the previous command with some pattern replaced: `^old^new`. For example: +```bash + echo foo + ^foo^bar # equivalent to: echo bar +``` - `pstree -p` is a helpful display of the process tree. @@ -185,7 +190,7 @@ Notes: - For a simple web server for all files in the current directory (and subdirs), available to anyone on your network, use: `python -m SimpleHTTPServer 7777` (for port 7777 and Python 2) and `python -m http.server 7777` (for port 7777 and Python 3). -- For running a command with privileges, use `sudo` (for root) or `sudo -u` (for another user). Use `su` or `sudo bash` to actually run a shell as that user. Use `su -` to simulate a fresh login as root or another user. +- For running a command with privileges, use `sudo` (for root) or `sudo -u` (for another user). Use `sudo bash` to actually run a shell as that user. Use `su` to login as another user and `sudo -i` to login as root. Use `su -` to simulate a fresh login as root or another user. - Know about the [128K limit](https://wiki.debian.org/CommonErrorMessages/ArgumentListTooLong) on command lines. This "Argument list too long" error is common when wildcard matching large numbers of files. (When this happens alternatives like `find` and `xargs` may help.) From 311cf092142db9cf90cd315b556bc428e2afe4bd Mon Sep 17 00:00:00 2001 From: Not Mark Date: Tue, 23 Aug 2016 10:34:30 -0500 Subject: [PATCH 2/5] Tried to make sudo/su section more clear --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3e32d5c..09a5d51 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,10 @@ Notes: - For a simple web server for all files in the current directory (and subdirs), available to anyone on your network, use: `python -m SimpleHTTPServer 7777` (for port 7777 and Python 2) and `python -m http.server 7777` (for port 7777 and Python 3). +- For running a command as another user, use `sudo`. Defaults to running as root; use `-u` to specify another user. Use `-i` to login as that user (you will be asked for _your_ password). + +- For switching to another user, use `su`. Add `-` to get an environment as if the user just logged in. By default this switches to root, but you can specify a user: `su - user`. You will be asked for the password _of the user you are switching to_. + - For running a command with privileges, use `sudo` (for root) or `sudo -u` (for another user). Use `sudo bash` to actually run a shell as that user. Use `su` to login as another user and `sudo -i` to login as root. Use `su -` to simulate a fresh login as root or another user. - Know about the [128K limit](https://wiki.debian.org/CommonErrorMessages/ArgumentListTooLong) on command lines. This "Argument list too long" error is common when wildcard matching large numbers of files. (When this happens alternatives like `find` and `xargs` may help.) From 1173274fd3461b96386f53d21c2b40ae3943f0db Mon Sep 17 00:00:00 2001 From: Not Mark Date: Tue, 23 Aug 2016 10:50:13 -0500 Subject: [PATCH 3/5] Ooops! Forgot to delete old line --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 09a5d51..c79c848 100644 --- a/README.md +++ b/README.md @@ -194,8 +194,6 @@ Notes: - For switching to another user, use `su`. Add `-` to get an environment as if the user just logged in. By default this switches to root, but you can specify a user: `su - user`. You will be asked for the password _of the user you are switching to_. -- For running a command with privileges, use `sudo` (for root) or `sudo -u` (for another user). Use `sudo bash` to actually run a shell as that user. Use `su` to login as another user and `sudo -i` to login as root. Use `su -` to simulate a fresh login as root or another user. - - Know about the [128K limit](https://wiki.debian.org/CommonErrorMessages/ArgumentListTooLong) on command lines. This "Argument list too long" error is common when wildcard matching large numbers of files. (When this happens alternatives like `find` and `xargs` may help.) - For a basic calculator (and of course access to Python in general), use the `python` interpreter. For example, From 94e7e0d1bcdecb951cdd700e663bb57296134ee7 Mon Sep 17 00:00:00 2001 From: Not Mark Date: Fri, 26 Aug 2016 09:50:24 -0500 Subject: [PATCH 4/5] Remove substitution trick for now --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index c79c848..4cdde00 100644 --- a/README.md +++ b/README.md @@ -101,12 +101,6 @@ Notes: cat hosts | xargs -I{} ssh root@{} hostname ``` -- To rerun the previous command with some pattern replaced: `^old^new`. For example: -```bash - echo foo - ^foo^bar # equivalent to: echo bar -``` - - `pstree -p` is a helpful display of the process tree. - Use `pgrep` and `pkill` to find or signal processes by name (`-f` is helpful). From d60f04de09b9bc65f839c5821df4c0a4285b7cf9 Mon Sep 17 00:00:00 2001 From: Not Mark Date: Fri, 26 Aug 2016 09:55:38 -0500 Subject: [PATCH 5/5] Clarification of `su` according to @neil-greenwood's suggestion in #450 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cdde00..c7af707 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ Notes: - For running a command as another user, use `sudo`. Defaults to running as root; use `-u` to specify another user. Use `-i` to login as that user (you will be asked for _your_ password). -- For switching to another user, use `su`. Add `-` to get an environment as if the user just logged in. By default this switches to root, but you can specify a user: `su - user`. You will be asked for the password _of the user you are switching to_. +- For switching the shell to another user, use `su username` or `su - username`. Include the `-` to get an environment as if the user just logged in. Omitting the username defaults to root. You will be asked for the password _of the user you are switching to_. - Know about the [128K limit](https://wiki.debian.org/CommonErrorMessages/ArgumentListTooLong) on command lines. This "Argument list too long" error is common when wildcard matching large numbers of files. (When this happens alternatives like `find` and `xargs` may help.)