简体   繁体   中英

Linux command 'll' is not working

我可以用我的用户运行 ll 命令,但不能用 sudo,它给我错误,因为找不到命令!

ll创建别名。

alias ll="ls -al"

Try sudo ls -l .

As ll is a shorthand for ls -l .

As it has been explained:

ll is actually an alias to ls -l

In your prompt, I would recommend using the following 3 commands when you are not sure about a command that you input:

  • type <command_name> will give you information about the command, in our particular case, the output will be: ll is aliased to 'ls -l'

    • which <command_name> will show you the path of the command you are going to use

    • whatis <command_name> will give you basic information about the command

Last but not least, alias ll="ls -al" will allow you to create the alias you are looking for. However to avoid redefining your aliases every single time you open a new shell. You will have to save them in your .profile or add them in your .bashrc file (use .bash_aliases file for this purpose and uncomment that section in your .bashrc ) in the home directory of your user.

For additional information, please have a look at the following link:

https://unix.stackexchange.com/questions/183496/how-to-create-permanent-aliases-on-unix-like-systems

That's expected because ll is defined in your profile (.bashrc in Ubuntu, for instance).

grep "alias ll" ~/.bashrc
alias ll='ls -alF'

Your .bashrc will not run when you sudo.

I am quite late, but ... In Debian 10 the command ll is commented (#) .

To make ll available just change yourr .bashrc file:

su gedit .bashrc

After in your text editor uncommnet as you wish:

# some more ls aliases alias ll='ls -l' #alias la='ls -lA'

.

In order to run ll with sudo, the user that is sudo'ed (superuser or another user, as specified by the security policy) needs an alias ll='ls -al' in his profile.

Note that even if defined, you may not be allowed to execute it by the security policy. To find out which commands you may execute type sudo -l

For some reason, alias was not working on my system, when I used with double quote (") or single quote (') . Once I removed all quotes , then it works with below command .

1: First, create an alias with alias ll=ls -als (without double/single quotes)

2: Now run this command ll and it will list all files & folders.

在此处输入图片说明

alias ll='ls -al' would work temporarily in my case. What I did is:

  1. Switched to root user
  2. echo "alias ll='ls -ahl'" > /etc/profile.d/ll.sh

It works smoothly :)

Check if the alias exists in ~/.bashrc which should be something like

alias ll = ls -al

sometimes after a bunch of changes (in my case installing python3.6 and it's libraries, etc) the bashrc file wasn't sourced to pick up the changes to it so just source the bashrc file using the command

source ~/.bashrc

Just doing this worked like a charm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM