Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

chroot(2) [minix man page]

CHROOT(2)							System Calls Manual							 CHROOT(2)

NAME
chroot - change root directory SYNOPSIS
#include <unistd.h> int chroot(const char *dirname) DESCRIPTION
Dirname is the address of the pathname of a directory, terminated by a null byte. Chroot causes this directory to become the root direc- tory, the starting point for path names beginning with ``/''. In order for a directory to become the root directory a process must have execute (search) access to the directory. This call is restricted to the super-user. RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate an error. ERRORS
Chroot will fail and the root directory will be unchanged if one or more of the following are true: [ENOTDIR] A component of the path name is not a directory. [ENAMETOOLONG] The path name exceeds PATH_MAX characters. [ENOENT] The named directory does not exist. [EACCES] Search permission is denied for any component of the path name. [ELOOP] Too many symbolic links were encountered in translating the pathname. (Minix-vmd) [EFAULT] Path points outside the process's allocated address space. [EIO] An I/O error occurred while reading from or writing to the file system. SEE ALSO
chdir(2). 4.2 Berkeley Distribution August 26, 1985 CHROOT(2)

Check Out this Related Man Page

CHROOT(2)						      BSD System Calls Manual							 CHROOT(2)

NAME
chroot -- change root directory SYNOPSIS
#include <unistd.h> int chroot(const char *dirname); DESCRIPTION
Dirname is the address of the pathname of a directory, terminated by an ASCII NUL. Chroot() causes dirname to become the root directory, that is, the starting point for path searches of pathnames beginning with '/'. In order for a directory to become the root directory a process must have execute (search) access for that directory. If the program is not currently running with an altered root directory, it should be noted that chroot() has no effect on the process's cur- rent directory. If the program is already running with an altered root directory, the process's current directory is changed to the same new root directory. This prevents the current directory from being further up the directory tree than the altered root directory. This call is restricted to the super-user. RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate an error. ERRORS
Chroot() will fail and the root directory will be unchanged if: [ENOTDIR] A component of the path name is not a directory. [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters. [ENOENT] The named directory does not exist. [EACCES] Search permission is denied for any component of the path name. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EFAULT] Path points outside the process's allocated address space. [EIO] An I/O error occurred while reading from or writing to the file system. SEE ALSO
chdir(2) WARNINGS
There are ways for a root process to escape from the chroot jail. HISTORY
The chroot() function call appeared in 4.2BSD. 4.2 Berkeley Distribution June 4, 1993 4.2 Berkeley Distribution
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

? question mark, how to get back to the root directory

hiyas I am trying to get back to the root directory: I went into MAIL directory and now I can't get back to the root directory. What are the commands... I have '?' coming up and I cannot proceed with this, HELP Cheers (1 Reply)
Discussion started by: etravels
1 Replies

2. UNIX for Dummies Questions & Answers

Message trying to list contents of directory

I'm getting this return whenever I try to do anything on a directory root# ls -al /directory ls: .: Value too large to be stored in data type. total 0 I can change directory down two levels but can not list contents of the root of this directory. ANy one seen this? (1 Reply)
Discussion started by: sallender
1 Replies

3. UNIX for Dummies Questions & Answers

Searching a directoy

Hi, How to search a directory and know it's path. Please Help. Thanks (3 Replies)
Discussion started by: gumsun
3 Replies

4. AIX

Help Using Grep command to Find the string in the files in the root directory

I want to serch for a string in all the files in the root directory. i want the search to be limited to only the files in the directory i.e the search to be done only in the files not in the sub directory. the approaches tried are 1)grep "pattern string" this command was serching the... (3 Replies)
Discussion started by: Subbu_Angeline
3 Replies

5. Shell Programming and Scripting

Verify the directory path

Hi, We have the csv file which contains the directory path and a file Eg:- Path resoureName /test/india/sample,abc.txt /test1/us/sample2,xyz.csv I have to verify above directory path which is exist or not in the server If so, i have to return the path.Moreover i have to validate the "/"... (1 Reply)
Discussion started by: sollins
1 Replies

6. UNIX for Dummies Questions & Answers

how to find a path within unix root directory

I need to know whether nyfile/mypath exists on the file system in the root directory. How to do this (1 Reply)
Discussion started by: ramky79
1 Replies

7. UNIX for Dummies Questions & Answers

Get directory address

what is the command that print the full address of the directory that im in it? (1 Reply)
Discussion started by: nirnir26
1 Replies

8. UNIX for Advanced & Expert Users

Damaged root directory ..

With the cpio command of a Unix File System for error I have replaced the directory “.. “ (when you give the command “ls -la” under root you see at the beginning the hidden directory “. “ followed by a hidden file who is called “..” ) I have the copy on a cartridge of the whole file system, but... (3 Replies)
Discussion started by: SISQUEZ
3 Replies

9. HP-UX

change directory path

Hi, when ever i login my unix system it is going to root directory....how can i change it specified directory.. (3 Replies)
Discussion started by: rsivasan
3 Replies

10. Solaris

Access Denied

Hi All, I have a root access for one of the server. But, when i try to cd one particular directory i will get the access denied message. Even though that particular directory is created under root. What would be the cause for this? I really wonder if any one have answer for my... (20 Replies)
Discussion started by: Sricharan21
20 Replies

11. Shell Programming and Scripting

Help regarding a Perl Program

I want to traverse a durectory for a particular file. Situataion is like this. Path is ABC/a/c/g. it has around 100 folders in it. Search a directory which has word "*latest*" in its path. and then from the latest go through z/x/c to file final.html. In total, i want it to go through... (4 Replies)
Discussion started by: hemasid
4 Replies

12. UNIX for Dummies Questions & Answers

Duplicated file names with home directory symbol appearing in ls .

Why are there duplicated file names listed when I execute ls ? Result of my ls /root/Desktop : aaa ca new file~ what what~ Thanks. (4 Replies)
Discussion started by: Hijanoqu
4 Replies

13. UNIX for Dummies Questions & Answers

Read Only user in Vsftpd

HI I have set up vsftp on my Red hat server. Chroot has been set up to control access to each user and folder directories. This all works fine. But i have one directory where i want to chroot but ensure that the ftp access is read only. Any help appreciated thanks Treds (1 Reply)
Discussion started by: treds
1 Replies

14. UNIX for Beginners Questions & Answers

Why does a fakechroot exist?

I am really confused as to why a tool like fakechroot exists and what does it do. Chroot is an ability only for root users, correct? Then a tool that allows to bypass that is clearly a security flaw, correct? When and why would you need something like this? Is there any relation between... (7 Replies)
Discussion started by: sreyan32
7 Replies

15. UNIX for Advanced & Expert Users

Stop root from writing to directory

Is there a way to stop root from writing to a directory? I already tried chattr but that did not seem to work. chattr +i directory (12 Replies)
Discussion started by: cokedude
12 Replies