Linux going to root directory

How to browse root directory in linux mint?

says permission denied. Also I need to list the files starting with «abc» inside root directory. When listing files I must not include sub directories of /root. Can anyone help?

First off, you can’t use sudo with cd . if you need a root propmt, either execute the shell as root, or run sudo -i to run a series of commands as root. second, the root dir is / , not /root. or better yet, use sudo ls . /root to run your list command as root.

2 Answers 2

First of all, the root directory is / , not /root . /root is the home directory of the root user. Also, you don’t need sudo to list its contents. Just do:

To list all files (and directories) starting with abc , you want

To move into the root directory, just run cd / .

The command ls /abc* treats files and folders differently. The glob is expanded by your shell (bash) to all files and folders beginning with abc . ls will list the contents of any directories you give it. For example:

$ ls -l total 4 -rw-r--r-- 1 terdon terdon 0 Jan 23 20:25 dfile.txt drwxr-xr-x 2 terdon terdon 4096 Jan 23 20:25 dir1 $ ls dir1 -rw-r--r-- 1 terdon terdon 0 Jan 23 20:25 file2.txt 

So, I have a directory called dir1 and a file called dfile.txt . The directory contains another file, file1.txt . Now, if I run ls d* , it will list the file dfile.txt and the contents of the directory dir1 :

$ ls d* dfile.txt dir1: file2.txt 

If you don’t want ls to list the contents of directories, run it with the -d option. As explained in man ls :

 -d, --directory list directory entries instead of contents, and do not derefer‐ ence symbolic links 

To list all files and directories beginning with abc in / without listing dirctory contents, run this:

Alternatively, if you want only files, use find :

$ find / -maxdepth 1 -type f -name "abc*" 
 -maxdepth levels Descend at most levels (a non-negative integer) levels of direc‐ tories below the command line arguments. -name pattern Base of file name (the path with the leading directories removed) matches shell pattern pattern. -type c File is of type c: d directory f regular file 

Источник

Linux how to get to the root directory

You can’t access to the root folder because that folder is owned by root and it’s user folder. Also using nautilus by Pressing Super + F2 key and typing Changing permissions of root folder.

Читайте также:  Kyocera m2035dn ppd linux

I Can’t access the root folder

There are two different folders called the «root» folder: / (the root of the filesystem, which is really the only folder that should ever be called the «root folder»), and /root (the root user’s home directory). During the normal course of operation (i.e., except while performing administrative tasks), users cannot create new files in / or /root .

You should not change the ownership or permissions of either directory (changing them for / in particular could break things very badly, perhaps even beyond creating security problems depending on what assumptions your applications and services make about the ownership and permissions of / ).

If you have the gksu package installed, you can run gksudo nautilus to open a root-owned file browser window. If you do this, please be extra careful to only use it for tasks where you must be root, and to close it when you’re done (so you don’t later confuse it with an ordinary Nautilus window).

If you don’t have gksu installed and don’t want to install it, sudo -i nautilus or sudo -H nautilus are reasonably safe. (In contrast, if you were to use plain sudo nautilus , you might have to fix some things in your home directory to get Nautilus to work properly again when you’re not running it as root.)

However, usually you don’t need to do that either. You rarely have to manually edit the top-level contents of / or the contents of /root . I recommend providng more information—or asking a new question—to explain exactly what you’re trying to accomplish. The particular task you need to do will determine how you should proceed.

Finally, a note on lost+found . This stores files recovered in filesystem repair operations. Since such files could be from anywhere in the filesystem, it’s necessary to require root permissions to access them (or any information on the system could potentially be accessed by someone who is not an administrator). If you think there may be files there that you wish to reclaim, you can check by running

in a Terminal window ( Ctrl + Alt + T ).

If there are files there that you want, then you can copy them out (and if their ownership and permissions don’t give you the necessary access, change them). You can do that as root from the Terminal with cp , chmod and chown (run as root with sudo ), or with a root-owned Nautilus window as described above.

Читайте также:  Linux tcpdump to pcap

If you need to change ownership and permissions for files, then:

  1. make sure not to do so for more files than necessary—for example, some people accidentally change ownership or permissions for large parts of the system and then have to reinstall, and
  2. I recommend this guide for understanding the ownership/permissions system in Ubuntu (which also applies to most other Unix-like OSes). Wikipedia may help too.

Yes, this is normal to Ubuntu and every Linux distributions. You can’t access to the root folder because that folder is owned by root and it’s user folder.

But, you can access that folder if you really want by using sudo -i command in the terminal. Be warned that, if you mess anything, it is your responsibility .

Also using nautilus by Pressing Super + F2 key and typing gksu nautilus

Changing permissions of root folder.

Assuming you want to change the permission of root user’s home folder, which is /root folder, I would say, it is very bad idea to do so. Because, if you change the permission of root’s home and you delete or modified some crucial file there, This may result in totally un-usable system. You may need to install Ubuntu from scratch.

But, if you really want it, the command is chmod:

will let you gain access to the /root folder. See the manual page for chmod command here.

To learn more about File permissions, Read this

You need to do the following:

Edit /etc/ssh/sshd_config using sudo nano /etc/ssh/sshd_config

Look for the line that says:

Make sure it looks like the below line:

No hashes (i.e., #) and the yes is there.

Linux root directory and partition, The running system (or more correctly a process in the running system) has a «root directory», referred to by / .

Linux Root Directory

The root directoy is on top of all other directories. Its name is /. We can find within this Duration: 0:59

Linux Command Line (13) The Root User

The Root User is the default privileged user on the file system and can do anything to any file on Duration: 8:47

The root directory in linux

New! Watch ads now so you can enjoy fewer interruptions. Got it
Duration: 1:20

How do I find the root of the directory I’m currently in for Linux

I believe you’re looking for:

Just the environment variable of $PWD

The pwd command is what you are looking for.

How do you get to the root directory that I need to delete a file in?, From a cli/terminal you can use the sudo command to assume root privileges, which you need to delete stuff from your root directory.

Читайте также:  Linux kernel stable git

How to access /root directory from a browser?

As you are trying to access using file:// urls, so access is to the local machine and therefore the directories you can see will be limited to whatever the logged on user that ran the browser, can see.

/root is not a particularly special directory except that it is the home directory of root user. So root user obviously can see it. So will anybody else who is either in the group the /root directory is set to (usually root group) or indeed anybody on the machine if the /root is set world readable.

Note that contrary to the comment posted to your question, to do what you ask, it should be enough to set the directory rights to 0755 — group and world readable instead of 0777 which sets the directory to world writeable and is therefore even bigger security risk.

By and large there shouldn’t be anything in /root dir of any interest, so the whole idea is a security risk with no inherent value.

How to access homedir by root user, Try cd /root . ~ is normally just a shorthand for the home directory, so if you are the regular user person then cd ~ is the same as cd

How do I get the root directory of a process programmatically?

I don’t know whether there is another way, but lots of programs rely on the machine readable files in /proc to get additional information about processes and there’s nothing inherently wrong with that.

Here’s an example of a process finding its own root dir programmatically via /proc :

#include #include #include int main() < char foo[PATH_MAX+1]; int count = readlink("/proc/self/root", foo, PATH_MAX); if(count < 0) < perror("Can't find root dir (is /proc mounted here?)"); >else < foo[count]=0; printf("My root dir is %s\n", foo); >> 

Well there isn’t. There exists a command to do this which is pwdx, here is its code https://elixir.bootlin.com/busybox/latest/source/procps/pwdx.c. It also reads root dir from /proc. You can get the pid of your process using getpid function.

One simple way is to just use a for loop. This is a one-liner that will print out the root directory of each of the processes you wish (proc1, proc2, proc3):

for i in $(ps -ef | grep -E ‘proc1|proc2|proc3’ | awk ‘< print $2 >‘); do ls -ld /proc/$i/root; done

«/root» directory is missing in Yocto build, /root is usually root’s home directory. Check your /etc/passwd or equivalent to see where root ‘s home directory is. – muru

Источник

Оцените статью
Adblock
detector