Linux
The open-source OS.
Linux Monitoring Tools
SELinux
See SELinux
RSysLog
See Rsyslog
User Management
Package Installer
See the apt-get manual.
Favourite Commands
find and grep — Search for a String
Recursively searches / for string and prints the results to the terminal. The -i flag ignores case sensitivity.
tail — Live View of a File
Gives you a scrolling view of the log file. As new lines are added, they appear in the console.
ls — List Directory Contents
Use the long format to show owner and permission details:
Include hidden files and directories as well:
ps — Report a Snapshot of Current Processes
Show processes for the current user only:
Show processes for all users:
Show all processes, including those without an associated terminal:
See Linux Monitoring Tools for details and analysis of using ps.
rm — Remove Files or Directories
Remove a single file:
Remove a directory and all its contents (use caution):
Force removal of unwritable files (use extreme caution):
chown — Change File or Directory Ownership
Change the file owner:
Change the file owner and group:
Change a folder and its contents (use caution):
chmod — Change Access Permissions
Make a file readable, writable, and executable by the owner, group, and others:
Make a file executable:
Change a folder and recursively apply the permissions to its contents (use caution):
How to Determine chmod Codes
chmod is a tricky function because it uses numbers to alter file and folder permissions. These numbers are based on a recognizable pattern that produces the required permissions.
chmod uses three octal numbers (for example, 777). Each number maps to read, write, and execute permissions for one of three user groups:
- The first number sets permissions for the owner or creator of the file or folder. This may be root, but it is typically the user who created it.
- The second number sets permissions for the group that the file or folder belongs to. For example, files created in
/etc/apacheor/var/wwware typically part of thewww-dataorapacheuser group. - The third number sets permissions for all other users. For user-created files, this is often the field you will edit because other programs or users may need access.
Each number is an octal value from 0 to 7. It can be represented in binary using three bits:
- The first bit is read permission.
1means enabled and0means disabled. - The second bit is write permission.
1means enabled and0means disabled. - The third bit is execute permission.
1means enabled and0means disabled.
Examples
To give a file read, write, and execute permission for itself; read and execute permission for the group; and read permission for everyone else:
- Read/write/execute =
111=7. The first number is7. - Read/execute for the group =
101=5. The second number is5. - Read for everyone else =
100=4. The third number is4.
To set these permissions, run: