I am new to debian (on a Raspberry Pi), and it comes with mistakes...
Trying to give chmod permissions over the /usr/ files to my login (pi), I made a mistake, confusing "-" with "+". I executed the commande line :
$ sudo chmod -rwx /usr pi
wich gets me in a bad situation :
I cannot execute anythong anymore because bash won't load.
After reboot, and logged as pi, same issue with this errors :
ERROR: ld.so: object '/usr/lib/arm-linux-gnuabihf/libcofi_rpi.so' from /etc/ld.so.preload cannot be preloaded: ignored
- bash: id: command not found
- bash: [: : integer expression expected
- bash: /usr/share/bash-completion/bash_completion: Permission denied
pi#raspberrypi:~$
and from there, my attemps to give chmod permissions to /usr/ are useless, because I don't have permissions at all...
most commands dont't work (startx, or else), as I get an error :
- bash: startx: command not found
How can I get out of that situation without restarting from scratch ?
Thanks a lot for your help !
Update
I actually found a list with many username/password combinations for different distributions often used on Raspberry. So check first, if your distribution is in there (I guess either Debian or Raspbian) and try the passwords there at the login prompt. If they do not work on SSH, try them directly (root login via SSH could be disabled).
Old entry
The Debian distribution for raspberry does not seem to have a password for root set by default. Thus, you cannot login as root. I guess, due to the access changes you cannot execute sudo?
So, the whole problem has to be solved from another operating system: Insert the SD card into another PC. If you do not have linux, you can boot it with a live CD like Ubuntu or Knoppix.
From there you can mount the SD card:
mount /dev/sdX? /mnt
sudo chmod 0755 /mnt/usr
Here X is variable and you have to find it out. Best is, you insert the SD card after the whole system has booted. Then the SD card should have the highest letter (e.g. d, if you have three other harddisks in your PC). The question mark ? has to be replaced with a number (probably 1).
You will have to log in as root. so that you can ignore the permissions you have set, and then run:
chmod 0755 /usr
Related
long story short,
1.my PATH got messed up so the zsh throws an "command not found" error in the terminal
tried to uninstall and reinstall the homebrew to see if that does anything - it did not.
now sudo throws me an error
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
the reason why(well my guess) sudo throws this error that is that while
I manually delete the files as the homebrew recommended, I must have deleted or done something in
/usr/local so now sudo uid is not 0 anymore.
I have tried
mount -uw /
chown 0 /private/etc/sudoers
exit
and these instructions
A. https://apple.stackexchange.com/questions/157772/sudo-etc-sudoers-is-owned-by-uid-501-should-be-0?fbclid=IwAR0HPT64TzzkuKs1ymsqb2l8HThXqRpGifX_QAdzrK5z5XgecavTzWiQVh0
B. https://forums.macrumors.com/threads/not-able-to-use-sudo-commands-in-terminal.2101126/?fbclid=IwAR3BL-Sajkrsp02i5MCAKM7DZ0C83xUFOg9pzRhpG1hLrzpk9FbnDbbjoaM
but none of them worked.
What is the last thing I can do?
If I delete the drive and re-install it(disk utility), will it also change the sudo problem?
That is, of course, the last thing I would like to do. but I am considering it now.
Any thoughts?
HELP!
After digging everywhere, I found the answer here,
My sudo command not working
One of the main issues I had was that the sudo uid set to 501 instead of 0.
#GordonDavisson had a solution using "Script Editor" and run the code
do shell script "chown root:wheel /etc/sudoers; chmod 440 /etc/sudoers; chmod -N /etc/sudoers" with administrator privileges
as he mentioned.
This successfully changed my root. I checked it by running
ls -l /etc/sudoers
in the terminal.
After this, I could re-install the homebrew.
Though I encounter unusual steps, where homebrew was running,
it asked me several times to enter the password for different stages
which did not happen before.
But after re-installing the Homebrew, I changed my $PATH
export PATH=$PATH:/usr/local/git/bin:/usr/local/bin
and now I can live again!
-bash: /var/lib/rancid/.bash_profile: Permission denied bash command not found
I am trying to switch between the users ( krypton & rancid) in ubuntu 16.04 with
su - . A few days back it worked perfectly, but don't know what happened now. The above warning message is coming.
When I am working as krypton user ~$ is showing
But when I am trying to switch to rancid using su - rancid, the above error is coming and entering into the user with /$ at the beginning. I am not able to run some commands and it's interrupting me.
Please give me a solution. I am wasting all my time with this.
First, check the permission of your /var/lib/rancid/.bash_profile file, and all parent folder. You can ls -ld them each, and put output here.
Then, you may check what there is in your ~/.bashrc file.
Running bash on windows 10, the simple syntax below works when I SSH to my webserver, but not when I exit out and am on my local machine. It doesn't give me an error, but I can see permissions are unchanged. I have to checked that I am set up as an administrator on my computer. Is this an error or is this just a consequence of the local operating system being windows? IF the later, it makes me question the value of using bash on windows if common operations such as this won't work.
$chmod 644 filename
To enable changing file owners & permissions, you need to edit /etc/wsl.conf and insert the below config options:
[automount]
options = "metadata"
Do this inside the WSL shell, potentially needing sudo to edit/create the file.
This may require restarting WSL (such as with wsl --shutdown which is a Windows command, not one within WSL) or the host machine to take effect. This has been possible since 2018:
You can now set the owner and group of files using chmod/chown and modify read/write/execute permissions in WSL. You can also create special files like fifos, unix sockets, and device files. We’re introducing new mounting options with DrvFs for projecting permissions onto files alongside providing new Linux metadata on files and folders.
[cite: Microsoft Dev Blog]
You can also temporarily re-mount a drive with the following commands:
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata
...but please note, the command only takes effect in session scope. If you exit current bash, you'll lose your settings (credit: answerer Amade).
Reference:
Automatically Configuring WSL
There was an update to WSL recently (source), which lets you change permissions to files (Insider Build 17063).
All you have to do is to run:
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata
Both Amades and Chaos answers are correct.
But it only works for local drives not for mapped network drives. Z: is one of my network drives. Same operation on /mnt/c/Users/xxx/ works fine.
$sudo mount -t drvfs Z: /mnt/z -o metadata
$touch test
$chmod +w test
chmod: changing permissions of 'test': Operation not permitted
This is a known issue, see drvfs: metadata (chmod\chown) possible for mounted SMB drives?
I'm on MAC OSX. I added these lines in my ~/.bash_profile :
PATH="/usr/local/stardog/bin:${PATH}"
export STARDOG_HOME=/data/stardog
export PATH
Then, in command line, I execute
cp stardog-licence-key.bin $STARDOG_HOME as the quick-start documentation states.
But, this seems useless, because when I execute sudo stardog-admin server start, it says :
A Stardog license was not found.
The license file 'stardog-license-key.bin'
should be in your Stardog Home directory 'xx/xx'.
xx/xx is the current directory when I launch this command ... but stardog home directory is supposed to be /data/stardog, not my working directory !
How to tell stardog his actual home directory ?
Fine (and sorry), I did not mention some elements : I executed the command stardog-admin server start with sudo (as seen in the last edit of my question).
Reasons :
I launched this command with sudo because I needed some permissions to start stardog properly.
Problem : With sudo, stardog home is not the one defined in my previous .bash_profile anymore.
Solution : I give (owner) permissions to myself on the directory $STARDOG_HOME with the command sudo chown -R myUsername /data/stardog
Open a new bash, type stardog-admin server start without sudo, it works.
I created an EC2 instance (Ubuntu 64 bit) and attached a volume from a publicly available snapshot to the instance. I successfully mounted the volume. I am supposed to be able to run a script from this attached volume using the following steps as explained in the tutorial:
Log in to your virtual machine.
mkdir /space
mount /dev/sdf1 /space
cd /space
./setup-script
The problem is that, when I try: ./setup-script I got the following message:
-bash: ./setup-script: No such file or directory
What is the problem ? How can I search for the ./setup-script in the whole machine ? I'm not very familiar with linux system. Please, help.
For more details about the issue: Look at my previous post:
Error when mounting drive
# Is it a script or an executable ?
file /space/setup-script
# Show us it is readable and marked executable
ls -l /space/setup-script
# Mark it executable
chmod a+x /space/setup-script
# Then try running it again? If you know it is shell script you can:
bash /space/setup-script
If still not working, then we get into why it wont execute.
grep space /proc/mounts
Does the options it have noexec ?
Try mount -o remount,exec /space now try your instructions again.
NOTE: All commands presume you are 'root' user or you can 'sudo' each command.
It is possible that you have mounted the wrong device. I've just recalled a trick you can use to find the device name of an EBS volume in Linux, since it is often different from the device name reported in the AWS console. First unmount the device in Linux, then detach it from the instance using the AWS console, so we go back to the original state. Now run this command in Linux:
cat /proc/partitions
The command will show the volumes currently attached. The next step is to attach the volume to the instance using the AWS console, and then to run that same command again in Linux. You should see an additional line appear. This line will tell you the name of the device to mount. For example, I get this output in my Ubuntu instance:
major minor #blocks name
202 1 8388608 xvda1
202 80 8388608 xvdf
The first line was already there before I attached the volume, so I know this is my root volume. The second line is the one that appeared, so in this case, the device to mount would be /dev/xvdf.