unable to cd into /var/log/audit
Code:
cat /etc/os-release Code:
NAME="Fedora Linux" Code:
ls -l /var/log/ | grep audit So i tried to cd using sudo Code:
mahesh@fedora:/var/log$ sudo cd audit Do i have to change the file permission? |
Quote:
|
Quote:
Quote:
From your words, sudo cd audit => i started the shell with sudo privileges Quote:
Quote:
Or it never reached audit directory.? |
Quote:
But it is awesome to know that i can change the shell with this command sudo -s Code:
mahesh@fedora:/var/log$ sudo -s visudo Code:
## Allows people in group wheel to run all commands Code:
%wheel ALL=(ALL) /bin/ls, ... Because my shell become root@fedora Code:
## Allow root to run any commands anywhere |
Be careful! Linux denies privileges to ordinary users for a good reason. It is rather easy to do something destructive when playing about as root. Yes, you can cheat by calling up a root shell, but it is always safer to use sudo. Having to prefix "sudo" to a command is psychologically useful: it reminds you that you are about to wield a potentially dangerous power and that you need to visually check the command for potential trapdoors before you press Enter.
Being a member of the wheel group does not make you root. I just tested it (I am a member of wheel on my machine and my sudoers file has the same line in it as yours does) but I still can't mount a partition that has been set as non-user-mountable or read the sudoers file. In other words I can use the commands but the result is not necessarily what I want. Edit: I must have had a memory lapse! Of course it means that you can use sudo with any command, not just with some. It does not apply to commands used without sudo. |
Quote:
Quote:
But as it was mentioned your shell completed the command you specified and exited. At the end you returned back to the initial shell and also into the initial directory. You can check it for example by executing: Code:
sudo bash -c "cd audit; pwd; echo here; ls -l" |
Quote:
Quote:
|
Quote:
I thought linux is easy to learn. It seems it is a life time learning... Man page is really confusing me. I am not able to understand clearly what a man page is trying to explain. So using youtube and some books. But i am not happy. Can you please suggest me a book which can teach me the basics as well as advance concepts of linux. Just basics is not enough. When i try to learn about networking commands, Those are really difficult for me. It seems i need networking knowledge to understand about those commands. Instead of man pages, Please suggest some good linux books. So i can gain some knowledge.. Thanks a lot for your help |
Quote:
|
Quote:
Quote:
Quote:
Quote:
https://www.youtube.com/watch?v=61yMjSjgnVc |
Quote:
Quote:
Quote:
Quote:
|
sudo runs one external command.
But a working cd must be an internal (shell builtin) command. For some reason there is also an external cd command in many Linux distros: Code:
type -a cd Code:
sudo cd /etc Test it in the shell: Code:
/bin/cd /etc Behind the scenes the shell forks/clones another shell that execs/converts to the command. This is not necessary for an internal command. Another internal command: set Code:
type -a set Code:
sudo set -a Code:
sudo bash -c "cd audit; pwd; echo here; ls -l" which runs the internal cd command, an internal pwd command (that could be external as well), and an external ls command. |
Fascinating. Slackware does not include a separate cd command btw. I just checked.
|
Quote:
Open a new process, cd into somewhere and exit? |
A discussion is here
A temporary cd can make sense because a test -d just checks the attributes. But if you really need it then you can use a short embedded bash script: Code:
dirs_i_am_able_to_cd_into=$(find . -type d -exec /bin/bash -c 'cd "$1"' cd.sh {} \; -print) And directly in bash you can use a sub shell: Code:
if test -d "$dir" && (cd "$dir"); then |
All times are GMT -5. The time now is 07:22 AM. |