Last active
November 28, 2017 21:18
-
-
Save dmwasielewski/9ca2ce012224cb0ad95428fa3cd27232 to your computer and use it in GitHub Desktop.
Command Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Navigation File System: | |
pwd - outputs the name of the current working directory. | |
ls - lists all files and directories in the working directory. | |
cd - switches you into the directory you specify. | |
mkdir - creates a new directory in the working directory. | |
touch - creates a new file inside the working directory. | |
Manipulation File System: | |
less (view text files) "q" | |
file (classify a file's contents) | |
ls | |
Options modify the behavior of commands: | |
ls -a lists all contents of a directory, including hidden files and directories | |
ls -l lists all contents in long format | |
ls -t orders files and directories by the time they were last modified | |
Multiple options can be used together, like ls -alt | |
From the command line, you can also copy, move, and remove files and directories: | |
cp copies files | |
mv moves and renames files | |
rm removes files | |
rm -r removes directories | |
Redirection: | |
The common redirection commands are: | |
> redirects standard output of a command to a file, overwriting previous content. | |
>> redirects standard output of a command to a file, appending new content to old content. | |
< redirects standard input to a command. | |
| redirects standard output of a command to another command. | |
A number of other commands are powerful when combined with redirection commands: | |
sort: sorts lines of text alphabetically. | |
uniq: filters duplicate, adjacent lines of text. | |
grep: searches for a text pattern and outputs it. | |
sed : searches for a text pattern, modifies it, and outputs it. | |
Environment variables are variables that can be used across commands and programs and hold information about the environment. | |
export VARIABLE="Value" sets and exports an environment variable. | |
USER is the name of the current user. | |
PS1 is the command prompt. | |
HOME is the home directory. It is usually not customized. | |
PATH returns a colon separated list of file paths. It is customized in advanced cases. | |
env returns a list of environment variables. | |
Permissions: | |
chmod - modify file access rights | |
su - temporarily become the superuser | |
sudo - temporarily become the superuser | |
chown - change file ownership | |
chgrp - change a file's group ownership | |
777 (rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting. | |
755 (rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users. | |
700 (rwx------) The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others. | |
666 (rw-rw-rw-) All users may read and write the file. | |
644 (rw-r--r--) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change. | |
600 (rw-------) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment