1

I'm following Tools Used in 6.828 to configure.

$ sudo tar xjf binutils-2.21.1.tar.bz2

generate folder binutils-2.21.1

$ cd binutils-2.21.1
cd: permission denied: binutils-2.21.1
$ sudo cd binutils-2.21.1
sudo: cd: command not found

Permissions of this folder's Properties show me I have Read & Write access.

How could I go into this folder (and build it)?

$ ls -l
drwxrwx--- 18  500  500     4096 Aug 24  2011 binutils-2.21.1
-rw-r--r--  1 root root 18997755 Aug 26  2011 binutils-2.21.1.tar.bz2
drwxr-xr-x 21  500  500     4096 Apr 26 20:40 gcc-4.6.1
-rw-r--r--  1 root root 30117877 Jun 27  2011 gcc-core-4.6.1.tar.bz2
drwxr-xr-x 15 1001 root     4096 Apr 26 21:55 gmp-5.0.2
-rw-r--r--  1 root root  2024576 Apr 26 21:39 gmp-5.0.2.tar.bz2 
drwxr-xr-x  6 rahn rahn     4096 Apr 26 22:00 mpc-0.9
-rw-r--r--  1 root root   565953 Jan 19 05:11 mpc-0.9.tar.gz 
drwxr-xr-x  9 rahn rahn     4096 Apr 26 21:57 mpfr-3.1.4
-rw-r--r--  1 root root  1279284 Mar  6 21:43 mpfr-3.1.4.tar.bz2

Debian 8.4, zsh

  • Probably because you used sudo to extract the tarball, your ordinary user doesn't have the required execute permission in order to traverse the directory – steeldriver Apr 27 '16 at 0:45
  • @steeldriver tar can't be done without sudo. BTW, sudo tar works for other tar file – Rahn Apr 27 '16 at 0:48
  • Sure tar can be done without sudo if you place the tarball in an appropriate directory. The permissions on the extracted directory appear to be slightly unusual (drwxrwx---) - perhaps "the other tar file" extracts with r-x permissions for other which is why you can cd to that even though it's root-owned. – steeldriver Apr 27 '16 at 0:56
  • 1
    Being able to enter/traverse a directory requires execute permissions. Having read/write permission will not allow you to view a directory's contents. Please show us the output of ls -ld binutils-2.21.1 to show us exactly what permissions you have on that directory. – Ryan Apr 27 '16 at 1:07
  • 1
    ~/Desktop/MIT/xv6 sounds fine however if you already used sudo tar to extract it then it will be root-owned: you should be able to restore appropriate ownership using sudo chown -R $USER:$(id -gn) binutils-2.21.1. Or just start over without sudo. – steeldriver Apr 27 '16 at 1:43
2

cd is builtin command:

$ type cd
cd is a shell builtin

You can't run it via sudo You can use the following command:

sudo -i 
  • After sudo -i, I see nothing in ~/Desktop and my zsh hightlight gone. – Rahn Apr 27 '16 at 1:40
  • @Rahn , Yes, because you login into root user. – PersianGulf Apr 27 '16 at 20:17
  • use pwd command. It's abbriviation of "Print Working Directory". – PersianGulf Apr 27 '16 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.