AWS6: Practice User Commands

Here is another practice:

Here is another practice:

 

example linux commands file and folders

  1. 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:
    sudo adduser <newusername>
  2. 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):
    cd /var/www/html/ 

    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.

    mkdir <newfoldername>
  3. Then change the home directory in the “user” file called passwd. To change the home directories first,
    sudo vim /etc/passwd

    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.

  4. 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.
    touch <newfilename>
    mkdir <newfoldername>
  5. Next, look at the owners of the folders and change the owners and groups.
    chown <username> <foldername>
    chgrp <username> <foldername>
  6. If you have to switch users, use the “su” command. Remember, only “ubuntu” is a sudo user.
  7. 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:
    chmod 700 <filename>
    chmod 700 <foldername>
  8. To get out of a user, type exit.
  9. If you create the wrong file, use (rm) to remove the file. You may need to “sudo” if you do not own the folder.
    rm <filename>
  10. 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.
    rm -R <foldername>

Written by