Aliases not available when using sudo


Add the following line to your ~/.bashrc:

alias sudo='sudo '

From the bash manual:

Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases that may be set and unset with the alias and unalias builtin commands.

The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias. The characters ‘/’, ‘$’, ‘`’, ‘=’ and any of the shell metacharacters or quoting characters listed above may not appear in an alias name. The replacement text may contain any valid shell input, including shell metacharacters. The first word of the replacement text is tested for aliases, but a word that is identical to an alias being expanded is not expanded a second time. This means that one may alias ls to “ls -F”, for instance, and Bash does not try to recursively expand the replacement text. If the last character of the...

0 0
0 0

sudo allows a system administrator to delegate authority to give certain users—or groups of users—the ability to run commands as root or another user while providing an audit trail of the commands and their arguments.

Sudo is an alternative to su for running commands as root. Unlike su, which launches a root shell that allows all further commands root access, sudo instead grants temporary privilege escalation to a single command. By enabling root privileges only when needed, sudo usage reduces the likelihood that a typo or a bug in an invoked command will ruin the system.

Sudo can also be used to run commands as other users; additionally, sudo logs all commands and failed access attempts for security auditing.


Install the package.


To begin using sudo as a non-privileged user, it must be properly configured. See #Configuration.

To use sudo, simply prefix a command and its arguments with sudo and a space:

0 0

I have the following aliases in /etc/profile.

# System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi alias startapache="/usr/local/Cellar/httpd22/2.2.29/bin/apachectl start" alias stopapache="/usr/local/Cellar/httpd22/2.2.29/bin/apachectl stop" alias ll='ls -lG'

I just added the last three aliases. Now when I do

sudo su: I dont get these aliases picked up.

sh-3.2# startapache sh: startapache: command not found

but when I am not sudoing, I get this aliases (This is bash shell). But it does not start apache.

local:~ 112019$ startapache (13)Permission denied: make_sock: could not bind to address [::]:80 (13)Permission denied: make_sock: could not bind to address no listening sockets available, shutting down Unable to open logs

Other Tips. I'm trying to find/figure out if a computer using Ubuntu 16 had an...

0 0

Typically sudo will ignore any aliased commands from your .bashrc, .bash_aliases, or the alias command. For example, I use "ll" as an alias for "ls -lh". Typing "ll" will give me a long-listing of a directory's contents, while typing "sudo ll" will give me:

I learned this when I tried to create an alias for "shutdown" that would refuse to shutdown if rtorrent was running. Unfortunately you need root privileges to use /sbin/shutdown, and sudo would completely ignore the clever script I aliased as "shutdown". The solution is an additional alias:

The space following "sudo" tells bash to check if the command that follows the space is also an alias. From the bash man page:

Now my aliased shutdown script is called even though it's being run with sudo. I've heard of another solution (also an alias), but I haven't tried it (1) because this one works just fine, and (2) because I don't understand why it works (if it does work). Here it is:

I'm not sure if it's...

0 0

{"protip":{"public_id":"9cviza","title":"Use your aliases with sudo","body":"Normally, when using `sudo`, you don't have access to aliases that have been defined for your user. These aliases are useful of course, so it's nice to make them available in a sudo context.\r\n\r\nTo do so, simply add this line to your `.bash_profile`:\r\n\r\n`alias sudo=\"sudo \"` - *note the space after the second sudo*\r\n\r\nHow does this work?\r\n\r\nWhen running a command, only the first word is checked against your aliases. So `myalias` by itself will work, but running `sudo myalias` means that only `sudo` is checked against your aliases - not the second word `myalias`.\r\n\r\nThe trick of aliasing sudo to itself (plus a space!) works because \"[when] the last character of the alias value is a space or tab character, then the next command word following the alias is also checked for alias expansion.\" - *from the [bash...

0 0

hen in need of running a process with elevated privileges, there are a three main solutions. Firstly, you can login as root, but this can only be done with the root password and still carries some security concerns. Secondly, you can use su to run a single command as root, still, this requires the root password. Lastly, there’s sudo, if improperly configured, it is a security nightmare, but if done properly, which is very easy, it can maintain a secure system while allowing flexibility in day to day operations.

The first step to understanding the power and flexibility of sudo is in understand the aliases.

User Alias – This is exactly as it sounds. These are aliases for users or groups of users. They aren’t as common, though, as system groups are typically used instead.

Command Alias – The command aliases are commands or groups of commands.

Host Alias – The host aliases are typically the more difficult concept to understand, especially since the sudo...

0 0
packages not available when using aptget

location: - date: June 17, 2005
i have some packages that i don't seem to be able to get : 1) for dvd playback $ sudo apt-get install libdvdcss2 Reading package lists... Done Building dependency tree... Done Package libdvdcss2 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package libdvdcss2 has no installation candidate 2) for sound $ sudo apt-get install w32codecs Reading package lists... Done Building dependency tree... Done E: Couldn't find package w32codecs am i pointing to the wrong server / website in the repositories ? appreciate if anyone could let me know the right websites to add into the repositories. thanks very much.

Command not found when using a package installed with aptget

location: - date: July 6, 2015
I'm used to apt-get however today I'm stuck...

0 0

Sudo Aliases and Exclusions


Michael W. Lucas


Last time, we looked at the basic sudo(8) setup. The hardest part of using sudo is configuring its permissions file, sudoers. As you can imagine, once you have several different machines with multiple administrators all with different levels of privilege, sudoers quickly gets very complicated. Aliases can simplify sudo maintenance and greatly clean up your sudo configuration.

Basically, an alias is a group of users, hosts, or commands. When a user's duties change, you can just add them to the appropriate user alias to give them correct sudo privileges. If you want your system operators to be able to back up the system, but no longer restore data, you can remove the restore commands from their command alias. When you install a new server, adding the server name to the proper alias will allow you to instantly give system administrators the proper permissions to do their...

0 0

I have a different solution whereby you do not need to add sudo as an alias. I run Linux Mint 17.3 but it should be pretty similar to Ubuntu.

When you are root, then the .profile is run from its home directory. If you do not know what the home directory under root is, then you can check with:

sudo su echo $HOME

As you can see, the home of root is /root/. Check its contents:

cd $HOME ls -al

There should be a .profile file. Open the file and add the following lines:

if [ "$BASH" ]; then if [ -f ~/.bash_aliases];then . ~/.bash_aliases fi fi

Basically, what this bash script does is to check for a file called .bash_aliases. If the files is present, it executes the file.

Save the .profile file and create your aliases in .bash_aliases. If you already have the aliases file ready, then copy the file to this location

Re-launch the terminal and you are good to...

0 0

Permission denied

In order to run a script the file must have an executable permission bit set.

In order to fully understand Linux file permissions you can study the documentation for the chmod command. chmod, an abbreviation of change mode, is the command that is used to change the permission settings of a file.

To read the chmod documentation for your local system , run man chmod or info chmod from the command line. Once read and understood you should be able to understand the output of running ...

ls -l

... which will list the READ, WRITE and EXECUTE permissions for the file owner, the group owner and everyone else who is not the file owner or a member of the group to which the file belongs (that last permission group is sometimes referred to as "world" or "other")

Here's a summary of how to troubleshoot the Permission Denied error in your case.

$ ls -l # Check file permissions of foo -rw-r--r-- 1 rkielty users 0...
0 0

Linux has a robust permissions system. This is a very good thing, as it enables a clear separation of roles among users, especially between the root user and your average user. Sometimes, though, you might want your average user to have some or all of root’s privileges. In Linux, this is accomplished with sudo.

Just How Would I Use sudo Anyway?

In most cases, one simply adds “sudo” in front of a command that needs root privileges. For example, a normal user (here called “example”) is not ordinarily able to restart services from the command line: [~]# /etc/init.d/httpd restart
/etc/init.d/httpd: line 15: ulimit: open files: cannot modify limit: Operation not permitted
/etc/init.d/httpd: line 16: ulimit: open files: cannot modify limit: Operation not permitted
/etc/init.d/httpd: line 17: ulimit: open files: cannot modify limit: Operation not permitted
httpd: Could not open configuration file...

0 0

In computing, alias is a command in various command line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is provided by the DOSKey command-line utility.

An alias will last for the life of the shell session. Regularly used aliases can be set from the shell's configuration file (~/.cshrc or the systemwide /etc/csh.cshrc for csh, or ~/.bashrc or the systemwide /etc/bashrc or /etc/bash.bashrc for bash) so that they will be available upon the start of the corresponding shell session. The alias commands may either be written in the config file directly or sourced from a separate file, typically named .alias (or .alias-bash, .alias-csh, etc., if multiple shells may be used).

Creating aliases[edit]...

0 0

sudo ([2] or [2][3]) is a program for Unix-like computer operating systems that allows users to run programs with the security privileges of another user, by default the superuser.[4] It originally stood for "superuser do"[5] as the older versions of sudo were designed to run commands only as the superuser. However, the later versions added support for running commands not only as the superuser but also as other (restricted) users, and thus it is also commonly expanded as "substitute user do".[6][7] Although the latter case reflects its current functionality more accurately, sudo is still often called "superuser do" since it is so often used for administrative tasks.

Unlike the related command su, users must supply their own password for authentication, rather than the password of the target user. After authentication, and if the configuration file, which is typically located at /etc/sudoers, permits the user access, the system invokes the requested command. The...

0 0

An alias is nothing but the shortcut to commands. The alias command allows the user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display a list of all defined aliases. You can add user-defined aliases to ~/.bashrc file. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.

More about aliases

The general syntax for the alias command for the bash shell is as follows:

Task: List aliases

Type the following command:

Sample outputs:

alias ..='cd ..' alias amazonbackup='s3backup' alias apt-get='sudo apt-get' ...

By default alias command shows a list of aliases that are defined for the current user.

Task: Define / create an alias (bash syntax)

To create the alias use the following syntax:

In this example, create the alias c for the commonly used clear command, which clears the...

0 0

Before we proceed, it would be best to cover some basic user administration topics that will be very useful in later chapters. Adding Users

One of the most important activities in administering a Linux box is the addition of users. Here you'll find some simple examples to provide a foundation for future chapters. It is not intended to be comprehensive, but is a good memory refresher. You can use the command man useradd to get the help pages on adding users with the useradd command or the man usermod to become more familiar with modifying users with the usermod command.

The super user with unrestricted access to all system resources and files in Linux is the user named root. This user has a user ID, of 0 which is universally identified by Linux applications as belonging to a user with supreme privileges. You will need to log in as user root to add new users to your Linux server.

Debian Note: When installing Ubuntu Linux systems, you are prompted to create a...

0 0


sudoers - default sudo security policy module


The sudoers policy module determines a user's sudo privileges. It is the default sudo policy plugin. The policy is driven by the /etc/sudoers file or, optionally in LDAP. The policy format is described in detail in the SUDOERS FILE FORMAT section. For information on storing sudoers policy information in LDAP, please see sudoers.ldap(5).

Authentication and logging

The sudoers security policy requires that most users authenticate themselves before they can use sudo. A password is not required if the invoking user is root, if the target user is the same as the invoking user, or if the policy has disabled authentication for the user or command. Unlike su(1), when sudoers requires authentication, it validates the invoking user's credentials, not the target user's (or root's) credentials. This can be changed via the rootpw, targetpw and runaspw flags, described later.

If a user...

0 0



policy plugin determines a user's


privileges. It is the default


policy plugin. The policy is driven by the


file or, optionally in LDAP. The policy format is described in detail in the


section. For information on storing


policy information in LDAP, please see



Configuring sudo.conf for sudoers


consults the


file to determine which policy and and I/O logging plugins to load. If no


file is present, or if it contains no




will be used for policy decisions and I/O logging. To explicitly configure


to use the


plugin, the following configuration can be used.

Plugin sudoers_policy Plugin sudoers_io

Starting with


1.8.5, it is possible to specify optional arguments to the


plugin in...

0 0