Linux Commands Cheat Sheet

haha

Check User SUDO Permission

Command:

sudo -l -U $USER_NAME

Example:

# Without permission
-bash-4.2# sudo -l -U jenkins
User jenkins is not allowed to run sudo on localhost.

# With permission
-bash-4.2# sudo -l -U root
Matching Defaults entries for root on localhost:
    !visiblepw, always_set_home, match_group_by_gid, env_reset,
    env_keep="COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS",
    env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE",
    env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES",
    env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE",
    env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
    secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User root may run the following commands on localhost:
    (ALL) ALL
-bash-4.2#

Generate Log File and Show on Screen Simultaneously

Command:

$COMMAND | tee build.log 2>&1

Example:

``