Here is another practice:
Here is another practice:
- Look for the users. They can be in the owner, group or at the beginning of the line “logged in”. To add the new users:
[code]sudo adduser <newusername>[/code]
- Next, look for the current “pwd” or present working directory. If there is a “cd” command before it, that means that the current directory is the logged in users “home” directory and that should be changed. First, check that it exists, if not add the new folders by first navigating to the location (just an example location):
[code]cd /var/www/html/ [/code]
then create the file and folders. If the user creating the files/folders is not the owner of the current parent directory, use the “sudo” command.
[code]mkdir <newfoldername>[/code]
- Then change the home directory in the “user” file called passwd. To change the home directories first,
[code]sudo vim /etc/passwd[/code]
Remember vim is a text editor. Use the “i” to go into insert mode, and “esc” to get out of insert mode. To quit and not save changes, once out of insert mode use :q!. To save your changes use :wq. Be sure to change the file path to the one needed.
- To create a file you touch it. To create a folder you mkdir it. If you are in a folder you user owns, you can create the file/folder without sudo. If you are “ubuntu” and need to make the folders where “root” owns the parent directory, make sure to use the “sudo” command in the front.
[code]touch <newfilename>[/code]
[code]mkdir <newfoldername>[/code]
- Next, look at the owners of the folders and change the owners and groups.
[code]chown <username> <foldername>[/code]
[code]chgrp <username> <foldername>[/code]
- If you have to switch users, use the “su” command. Remember, only “ubuntu” is a sudo user.
- To change a permission on a file/folder, use the chmod command. Remember, it goes owner, group than other and read(4), write(2), then execute(1). So if the owner can rwx, it would be a 7. The command would be:
[code]chmod 700 <filename>[/code]
[code]chmod 700 <foldername>[/code]
- To get out of a user, type exit.
- If you create the wrong file, use (rm) to remove the file. You may need to “sudo” if you do not own the folder.
[code]rm <filename>[/code]
- If you create the wrong folder use (rm -R) to remove the folder/directory. Again, you may need to “sudo” if you do not own the parent folder.
[code]rm -R <foldername>[/code]