Lect03-04 - Bash + vi Flashcards
What is a shell?
The shell is a program that takes commands from the keyboard and gives them to the operating system to perform
What is bash?
Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell.
What is a terminal?
This is a program that opens a window and lets you interact with the shell.
File permissions:
What is the command to change permission for file.txt?
chmod <octal> file.txt</octal>
File permissions:
What does -
- chmod u+rw somefile
- chmod o-rwx somefile
- chmod a+r somefile
- chmod a=rx somefile
- This would give the user read and write permission.
- This will remove read/write/execute permissions from other users (doesn’t include users within your group).
- This will give everyone read permission for the file.
- This would give everyone execute and read permission to the file, if anyone had write permission it would be removed.
File permission:
What is -
- 777
- 755
- 700
- 666
- 644
- 600
- rwx rwx rwx
- rwx r-x r-x
- rwx — —
- rw- rw- rw-
- rw- r– r–
- rw- — —
What are the following file types indicated by the first character of ls -l output:
- -
- d
- b
- c
- l
- Regular file
- directory
- Block devices (SCSI or IDE disk)
- Character device (serial port)
- Link (points to another file or directory)
What are file attributes?
Linux file systems (like ext2, ext3, ext4) support what are called file attributes. Attributes are flags that can control what file operations are allowed to occur on a file or a directory. There are two that can be very useful for protecting forensic data from haphazard deletion or tampering. These are append only (a) and immutable (i).
- # lsattr <filename></filename>
- # chattr +i <filename></filename>
+/- A: No access time updates
+/- a: Append only
+/- s: Secure deletion
+/- i: Not possible to delete
What is a symbolic link?
Symbolic links are a special type of file that points to another file. With symbolic links, it is possible for a single file to have multiple names. Here’s how it works: Whenever the system is given a filename that is a symbolic link, it transparently maps it to the file it is pointing to. To create symbolic links, use the ln command.
Explain the following POSIX Character Classes:
- [:alnum:]
- [:alpha:]
- [:digit:]
- [:upper:]
- [:lower:]
- Alphanumeric characters
- Alphabetic characters
- Numerals
- Uppercase alphabetic characters
- Lowercase alphabetic characters
How do you change the default file permissions?
By default, when you create a file as a regular user, it’s given the permissions of rw-rw-r–. You can use the umask (stands for user mask) command to determine the default permissions for newly created files.
The umask is the value that is subtracted from the 666 (rw-rw-rw-) permissions when creating new files, or from 777 (rwxrwxrwx) when creating new directories. For example, if the default umask is 002, new files will be created with the 664 (rw-rw-r–) permissions, and new directories with the 775 (rwxrwxr-x) permissions.
To display the current value of umask, run the umask command without any options. To temporarily change your umask value, run the umask VALUE command. This changes the umask value only for the current shell. To change the default umask value permanently for a specific user, you need to modify the .bashrc file in the user’s home directory. For example, to change the default umask for user bob, just add the following line at the end of the /home/bob/.bashrc file.
To change the default umask value permanently for all users, you can use the following command:
pam-config -a –umask –umask-umask=VALUE