[colug-432] sed basics

Steve VanSlyck s.vanslyck at postpro.net
Thu May 14 20:38:28 EDT 2015


Here's what I've learned:

# Comment out the line permitting root login (even if already
commented), add a new line,
# and in that line change the option to no.
#
# Since the global optionis not specified, only the first line will be
changed, and only
# the first instance on that line.
#
# Note this script is really unsophisticated. It'll work, but only in
the sense of "Don't
# touch the stove at noon on May 1, 2015" will work.
#
# sed - call the sed stream editor
# -i     - edit the file in place
# -i.bak - after making a backup with the extension ".bak"
# ''     - specifics about what to work on
# s      - perform a substitution
# /      - delimiters (you can use different ones if you want)
# \n     - enter a newline
# ./sshd_config - the file, in the current directory, to be operated on

sed -i.bak 's/PermitRootLogin yes/# PermitRootLogin yes\nPermitRootLogin
no/' ./sshd_config

# Let's see if it worked
diff ./sshd_config.bak ./sshd_config



More information about the colug-432 mailing list