Reputation
Next tag badge:
107/100 score
19/20 answers
Badges
13 145 237
Newest
 Necromancer
Impact
~8.8m people reached

May
12
revised What is the correct pronunciation of 'Ubuntu'?
separated into paragraphs for increased readability; minor punctuation/capitalization improvements
May
12
revised How to list users with UIDs higher than 10?
shortened title without removing significant information; tweaked wording in body slightly for clarity; added tags
May
12
revised bash shell script
improved formatting; reworded slightly for clarity; added tags
May
12
reviewed Looks OK Ubuntu 14.04 LTS: Trying to install Ruby 2.0, but gnome-session-bin seems to be half installed
May
12
reviewed Looks OK have windows and ubuntu on same disk
May
12
reviewed Looks OK GDM and Lightdm don't work after update; KDM is ok
May
12
reviewed Looks OK How to setup Chromecast as second display?
May
12
reviewed Looks OK root partition disk is full, how to clear it?
May
12
reviewed Looks OK Trouble installing VLC
May
12
reviewed Looks OK Unity is broken after restart
May
11
comment Convert many music files to mp3
I suggest expanding this answer with more information about specifically how to install and use this utility to mass-convert audio files to mp3.
May
11
comment How to check the password entered is a valid password for this user?
I think this is actually quite practical, though I may be biased: it's the same method I used. Your implementation and presentation are quite different though--this is definitely a valuable answer. Whereas I used mkpasswd to generate a hash from user input and the existing salt (and included additional features and diagnostics), you've instead coded a simple Python program implementing mkpasswd's most important functionality and used that. I recommend you set IFS= when reading password input, and quote ${password} with ", so password attempts with whitespace don't break the script.
May
11
revised How to check the password entered is a valid password for this user?
added bullet point reminding readers they need to install the mkpasswd utility (via whois) to use this script
May
11
reviewed Approve DNS_PROBE_FINISHED_BAD_CONFIG error in Ubuntu 14.04
May
11
comment How to install package of R?
@Tim Images updated.
May
11
revised How to install package of R?
updated software installation icon images; added concrete example of deb line; tweaked formatting
May
11
comment Run only parts of a script as sudo, entering password only once
I think, strictly speaking, echo "$password" on the left side of a pipe is safe in a bash script. echo is a shell builtin; /bin/echo doesn't run when it's called as simply echo .... Some other shells have an echo builtin (dash, for example), but Bourne-style shells aren't required to have one. So I think echo "$password" | is acceptable in bash but may be best avoided in case someone ports the script to another shell without noticing the issue. I use a non-portable [[ instead of [ in that script to avert the same sort of problem. @KasiyA
May
11
comment How to check the password entered is a valid password for this user?
The successful authentications are logged also. sudo -l causes an entry to be written with "COMMAND=list". Btw (unrelated), while it's not objectively better to do so, using a here string in place of a here document achieves the same security goal and is more compact. Since the script already uses the bashisms read -s and &>, using if sudo -lS &>/dev/null <<<"$PASSWD"; then is no less portable. I'm not suggesting you should change what you have (it's just fine). Rather, I mention it so readers know they have this option too.
May
11
comment How to check the password entered is a valid password for this user?
This way looks excellent. Though it won't work on systems with uncommon sudo configs (as you say) and clutters /var/log/auth.log with records of each attempt, this is quick, simple, and uses an existing utility, rather than reinventing the wheel (so to speak). I suggest setting IFS= for read, to prevent false successes for whitespace-padded user input and non-padded passwords, as well as false failures for whitespace-padded user input and padded passwords. (My solution had a similar bug.) You may also want to explain how it must be run as the user whose password is being checked.
May
11
comment How can I read user input as an array in Bash?
Or simply ./array_test.sh < war_and_peace.txt.