Cyber Security II - Linux Commands
command1 | command2
"pipe" output from command1 to be input of command2
cat /proc/meminfo
display information about RAM
kill -9 pid
forcefully shutdown process number pid (crash program, do not wait)
kill pid
terminate process number pid
wc file
word count of file (output is lines, words, bytes in file)
tar cf file.tar files
Create file.tar by compressing files and storing them in it
tar czf file.tar.gz
Create file.tar by compressing files with gzip and storing them in it
tar xzf file.tar.gz
Extract files compressed with gzip from file. tar.gz
tar xf file.tar
Extract files in file.tar
fg 2
bring job number 2 to foreground
cd dir
change directory to dir
chmod +x file
change file mode, set file as executable
chown user file
change owner of file to user
touch file
create empty file named file
adduser username
create user account for username
cat /proc/cpinfo
display information about CPU
killall proc
kill every process associated with proc
ls -al
list all files in directory, details in long format
ls
list files in directory
mkdir dir
make directory named
grep
needle haystack search for term needle in file haystack
nano file
open file in the nano editor
cat file
print all contents of file
awk '{print $3}'
print values of column 3 of output (usually used with pipe command)
pwd
print working directory
command > file
redirect output of command1 to new file named file ( use >> to append)
rmdir dir
remove directory (if empty)
chmod -w file
remove write access for file
!!
run last (most recent) command again
!73
run previous command numbered 73 by history command
password username
set password for username (only root can change other user's passwords)
chmod 644 file
set read, write for owner; read-only for group and world for file
chmod 777 file
set read, write, and executable for owner, group, and world for file Permissions: 4 = read , 2 = write , 1 = execute , 0 = no privileges Use 3 digits for owner, group, world
uname -a
show "all" current operating system information (OS name, kernel #)
man command
show "manual" guide for command (press q to quit)
history 10
show 10 previous commands
top
show active processes sorted by resources used (press q to quit)
ps aux
show all processes, by all users, that are executing
w
show all users current logged in
more file
show contents of file in interactive reader (press q to quit)
date
show current date and time (date +"%r" to only show time)
whoami
show current username
head file
show first 10 lines from file
uptime
show how long system has been running
tail file
show last 10 lines from file
jobs
show list and status of jobs
which command
show location of command
history
show previous commands
bg
stop job and send to background
sudo command
switch user (to root or superuser) and do the following command Must be in "wheel" group to use sudo