I checked by doing :
cd /
then
cd home
after ls shows my directory malik
ls
malik
as shown in picture as well :
But I don't know why it is saying "No directory, logging in with" ?
The directory permissons says
Owner: root, Group: root, Others: cannot access
I think you created the directory as user root.
Change the directorys permissons with
sudo chown malik.malik /home/malik
The sudo command gives you temporary root permissons for a specified command. If you want to get temporary root permissons for more than one command use
sudo su
Take a look here about linux file / directory permissons (LPIC)
About the seconde error message:
su - malik
It seams to me that you have not set a home directory for the user malik. You find this settings in /etc/passwd. It should look like
malik:x:1000:1000:malik:/home/malik:/bin/bash
Hope that helps.
Best, me
Related
I am new to linux. I have a build.sh file which consists of a lot of mkdir commands and some rm commands. But as I have installed this new in my VB, each time I run the .sh file, it says "Permission Denied for creating directory" and fails.
So is there any way that I grant directory privileges to all users.
Can anyone help me with this
Add "sudo" in the beginning of the directory creation command i.e
sudo mkdir dir_name
The issue might be with the directory in which the mkdir command is being run.
Use the command ll or ls -l to check the directory permissions.
If your directory doesn't have write privilege for the current user, you can run
chmod -R u+w /path/to/directory
This might require you to use sudo if permission is denied.
If you want to enable it for all users, run
chmod -R ugo+w /path/to/directory
Alternatively, a quick fix would be to run the build.sh file as root
sudo /path/to/build.sh
However, this approach is not advised unless you always run it as root
We are using sudo users with limited commands to execute and assigned default home directory /home/sudouser but if that particular sudo user is running command cd \ its changing the directory to the main root directory /. This behaviour is totally insecure for us.
We need it such that if the sudo user is entering cd / or cd it changes directory to their home directory /home/sudouser
Please let us know how we can implement this?
Don't ever try to restrict a sudo user to only a directory or a command, a sudo user can by definition do what he wants.
In your case, having a script that assigns the home directory is I think a better idea. To solve the trouble of permissions look for the suid bit in permissions: http://www.linuxnix.com/suid-set-suid-linuxunix/
For example: create a sh file that has the following permissions: "-rwsr--r--" that is owned by root and as a group that can be accessed by the user whom you want to use the script.
Then in the file you create a simple script to execute the command to change default directory with let's say two parameters (username and directory)
As HDFS user (owner of a Dir), I'm unable to view all the directories
Here is a command sample:
[ec2-user#ip-172-31-33-161 ~]$ ls -ltr
drwxrwxrwx 2 hdfs hadoop 4096 Oct 7 22:39 cards2
[ec2-user#ip-172-31-33-161 ~]$ sudo su - hdfs
[hdfs#ip-172-31-33-161 ec2-user]$ ls -ltr
ls: cannot open directory .: Permission denied
The command
sudo su - hduser
will take change the user, and take you to the home folder of hduser.
The command
sudo su hduser
can be used to remain in the current working directory even after the user is switched.
Login to ec2 machine as you previously logged in with ec2-user, change the permissions of /home/ec2-user , atleast give read permissions to other users.
chmod 777 /home/ec2-user
It is not the issue with the folder you are trying to access from the HDFS user.
ls -ltr will read the current working directory and will list the files in it.
you switched the user and you are accessing the ec2-user directory (The directory path is same as we required).
After changing the permissions, you are able to see the sub folders in ec2-user aswell.
I hope it will work for you. Please let me know for additional help.
I want to create directory like below:
ajs#ajs-HP-Compaq-dc5800-Small-Form-Factor:/usr/local$ mkdir pgsql
mkdir: cannot create directory `pgsql': Permission denied
But I am getting error:
Permission denied
How can I resolve and create directory pgsql in this location /usr/local$
Kindly suggest me, hope for reply.
Thanks
You have to check your user name to have permission for creating directory in the folder /usr/local$
Check your permission for the folder by the command
ls -ltr /usr
Link to refer about file permissions.
You are getting a Permission denied error because you do not have access rights to create a directory in /usr/local. You can determine the access rights for these directories by using the stat command. The output will look something like this.
$> stat -c '%n %A %G %U' /usr /usr/local
/usr drwxr-xr-x root root
/usr/local drwxr-xr-x root root
Now double check who you are. You can use the whoami command or the id command invoked below twice to reveal both username and group.
$> id -un; id -gn
In the stat output, root:root owns both /usr and /usr/local and only the owner may create (write) new directories based on the access rights. In order to create the directories, I'd recommend either becoming root or trying the command with sudo. If this is not possible, I'm afraid you'll have to create the directory elsewhere or contact the administrator of that machine.
You probably have to be root to do such things in /usr/local.
/etc/apache2/sites-available/000-default.conf
What should I do to access this file
I want to change DocumentRoot From /var/www/html To /var/www
First check to see who owns the file:
ls -l /etc/apache2/sites-available/000-default.conf
It should probably be something like www-data. For the rest of this answer I assume the user is www-data, replace it with the correct user on your system.
Verify you have permissions to act as that user, e.g.:
sudo -u www-data id
This command just runs the id command as the www-data user, you may have to enter a password.
Edit the file as the owner of the file:
sudo -u www-data vi /etc/apache2/sites-available/000-default.conf
(or emacs or nano or whatever your favorite editor is).
If none of that works, the file permissions might be messed up, for example maybe the user of the file is not allowed to write to it. In that case posting the output of:
ls -l /etc/apache2/sites-available/000-default.conf
may be helpful in resolving your issue, but you probably can't go wrong by doing a:
sudo -u www-data chmod o+rw /etc/apache2/sites-available/000-default.conf
This grants the owner read and write permissions on the file, then try the edit again.
If none of that works please post the exact command you are running, and the exact error message.
You need to access this file as a root user. Issue the command
sudo -s
to get a root shell, then edit that file with the editor of your choice.
Just run this command and you can edit that file
gedit admin:///etc/apache2/sites-available/000-default.conf