Walker News

Easily Finding Granted Linux Command In Sudo List

For those who are familiar with Runas features in Windows, sudo is the Runas equivalent in Linux OS. In brief, sudo is a Linux program that used to run or execute another Linux command under the root or others Linux user privilege.

Once the sudo package installed, each of the non-root users will have to be granted Linux commands that are intended to run on root or other users privilege. The visudo is used to maintain the list of granted Linux commands for Linux users in /etc/sudoers file.
Next, the Linux user can run sudo -l to list or display all the Linux commands granted for him/her. By default, this sudo -l report comma-delimited Linux commands in a single long line!

The Linux administrators who have usually granted few tens or hundreds of Linux command will definitely find this default sudo -l listing being difficult to read, especially to find out or confirm that he/she is granted the correct Linux command in the right command path.

Here are at least two ways to reformat or modify the sudo -l report listing:
  1. This Linux command
    sudo -l | grep --color=auto Linux-Command-Here

    will highlight the targeted Linux command if you’re running GNU grep 2.5.1 (type grep --version to check the GNU grep version).

    For example, to check is the GNU tar command granted to you, type

    sudo -l | grep --color=auto tar
  2. Download the wsudo shell scripts, which is used to break the comma-delimited Linux commands in the long line to one record per line.
    For example wsudo | grep tar will only display the GNU tar command if it is found in the sudo -l report (means that the GNU tar is granted in sudo access list).

    You may also simply type wsudo to get a modified, reformatted sudo -l report listing, in the form of one granted Linux command per line.

Isn’t this trick makes the formatted sudo -l command output easier to read or locate the granted command in sudo access list?

Custom Search

  1. How To Reset Linux Forgotten Root Password – Walker News 03-07-07@16:40

    […] that have caused you to lost a Linux root password, as most of the time you’re forced to use sudo command for daily admin […]

  2. Create New Linux EXT3 File System In LVM – Walker News 11-07-07@17:21

    […] is another 3-minutes Linux guide for newbie on How to create or add new Linux EXT3 file system in Logical Volume Manager (LVM) with […]

  3. How To Fix Weird Character In Linux Man Page – Walker News 18-10-07@23:09

    […] Thereafter, the man sudoers will looks normal – render the proper characters instead of weird characters in the Linux man pages. (sudoers is the sudo configuration file – see also how to format the sudo –l output in more readable format) […]

  4. SSH Remote Port Forwarding In 3 Minutes – Walker News 28-10-07@23:23

    […] to setup or configure SSH REMOTE Port Forwarding in Linux (Walker-A) with OpenSSH […]

  5. Use Alias To Create Linux Command Shortcut – Walker News 07-12-07@01:57

    […] set gsudo as the Linux command shortcut to highlight a given command in sudo -l report, i.e. gsudo tar to highlight the tar so that a user could easily confirm that the command is […]

  6. DB2 SQL To Query Tablespace Free Pages Statistics – Walker News 24-02-08@04:52

    […] Execute db2 list tablespaces show detail for existing databases govern by the DB2 instance account (the scripts will have to run under the same account, otherwise use a sudo command), […]

  7. awk.sed 20-03-13@12:21

    The wsudo shell script can be found and download from this page.


2017  •  Privacy Policy