-
Notifications
You must be signed in to change notification settings - Fork 1
Basic UNIX and bash commands
Jennings Zhang edited this page Mar 22, 2018
·
15 revisions
CAPITAL LETTERS
describe a required argument.
[square brackets] indicate optional parameters, flags, or options.
The basic command syntax looks like this:
command --option PARAMETER
-
echo [string]
outputs the string. -
ls [-alh] [dir]
displays the contents of the directoryDIR
.-
ls -a
lists all files, including.
and..
, as well as hidden files (which filenames begin with.
). -
ls -l
lists files with metadata, such as permissions, owner, size, and date.-
ls -lh
reports the information in "human readable" format.
-
-
-
cd DIR
changes the current working directory toDIR
. -
mkdir DIR
creates a new directory. -
rmdir DIR
deletes an empty directory. -
rm FILE
deletes a file. (accepts multiple arguments) -
touch FILE
creates a blank file calledFILE
. -
cat
concatenates the input stream and prints to the output stream.-
cat FILE
prints the content ofFILE
-
cat > FILE
will write the standard input stream out toFILE
. End this command by pressing CTRL-D.
-
-
man COMMAND
shows the manual page forCOMMAND
. -
whatis COMMAND
shows a brief, one-line description ofCOMMAND
. -
sudo COMMAND
runsCOMMAND
with superuser (root) privileges. -
grep REGEX [file]
filters the input stream or file based on a regular expression.-
fgrep
orgrep -F
forces literal evaluation of string. - I strongly recommend you add
alias grep='grep --color'
to your~/.bashrc
file.
-
-
nano [file]
opens an easy-to-use text-based text editor. -
vim [file]
opens an advanced text-based text editor. -
ln -s TARGET LINKNAME
creates a symbolic link. -
sudo -s
enters$SHELL
as the root user. -
sudoedit FILE
edits a file as the root user. ($SUDO_EDITOR
must be set, recommendrvim
) -
dmesg [-H]
print the kernel ring buffer (debug messages produced by the kernel) -
journalctl -b [-r]
shows systemd log entries from the current boot.