Show Menu
Cheatography

sysadmin Juan's cheatsheet Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

commands miscel­lanea

the ps command,
which shows the status of running processes
vimtutor
tutorial for vim
rmdir
erases directory
whoami
tells what kind of user you are
passwd
set up password or change the one you have
xemacs ".ba­shr­c"
calls text editor
cat
scan docs. from conCAT­enate
ln
let you make links between files
stty "­funtion key"
lets you set up the function keys
stty -a
show the current function key
stty sane
fix the shell
ls ["ra­nge­"].["r­ang­e"]
looks for combin­ations that satisfy specif­ication
tail -"#"
displays the last # of lines of a text file
head -"#"
displays the first #of lines of a text file
less
show less of a text file
awk
organize data in in columns and rows
sort
sort lines of text files
clear
cleans the screen
man
manual
du
estimates the file memory usage
free
displays the amount of free and used memory in the system
df
report file system disk space usage
lsblk
command used to report info about block devices as follows
fdisk
manipulate disk partion table
uname
print system info
cat /proc/­cpuinfo
cpu info
lscpu
cpu info
sudo
gets root authority
grep
search for a string in a file
tar
creates, view or extracts from archive
find
find files with a pattern
ssh
remotely login
awk
controls output
gzip
creates a *.gz compressed file
shutdow
turn off the machine
kill
terminates a process
mount
it mounts file
ifconfig
view the newtwork interrface
whereis
find the address of a specific command
uptime
show the running time of the system
hostname
displays the system hostname
cal
show the month calender
bg
sends a process to the background
df
shows file system disk space
diff
serves to find differ­ences between to files
lspci
serves to visualize P.C.I. devices
top
used to manage top processes
ping host
send echo message to the host
dig domain
show the dns specif­ication for the domain
scp
allows to remotely copy files from one machine to another machine
ip addr
shows ip address and related inform­ation
expr
allows to perform some mathem­atical operations
env
permit to see the current enviro­nment variables
history
shows the last one hundred commands execute in the system
iwlist
displays wireless devices plus config­uration files
locate
find files by name
lshw
display some basic inform­ation about the machine
lsusb
display inform­ation about usb
nice
nice - run a program with modified scheduling priority
pidof
find the process ID of a running program.
split
serves to split large files in to smaller ones
sum
checksum and count the blocks in a file
watch
execute a program period­ically, showing output fullscreen

setting NFS tutorial

sudo yum install nfs-utils nfs-ut­ils-lib
install NFS
sudo systemctl enable rpcbind; $ sudo systemctl start rpcbind; $ sudo systemctl enable nfs-se­rver; $ sudo systemctl start nfs-se­rver; $ sudo systemctl start nfs-lock; $ sudo systemctl start nfs-idmap
commands to start the service in charge of the service's functi­onality
$ sudo mkdir /NFSsh­are­dFo­lder; $ sudo chmod –R 0755 /NFSsh­are­dFolder
commands to create and prepared a folder
$ sudo nano /etc/e­xport
open nano to modify the export file
/NFSsh­are­dFolder 172.25.0.0­/1­6(r­w,s­ync­,no­_ro­ot_­squ­ash­,no­_al­l_s­quash)
add this line to the export line
$ sudo systemctl restart nfs-server
restart the NFS server
$ sudo firewa­ll-cmd --perm­anent --add-­por­t=1­11/tcp; $ sudo firewa­ll-cmd --perm­anent --add-­por­t=8­75/tcp; $ sudo firewa­ll-cmd --perm­anent --add-­por­t=2­049­/tcp; $ sudo firewa­ll-cmd --perm­anent --add-­por­t=2­004­8/tcp; $ sudo firewa­ll-cmd --perm­anent --add-­por­t=4­295­5/tcp; $ sudo firewa­ll-cmd --perm­anent --add-­por­t=4­666­6/tcp; $ sudo firewa­ll-cmd --perm­anent --add-­por­t=5­430­2/tcp; $ sudo firewa­ll-cmd --reload
commands to open and configure approp­riate ports
move to the client
to continue the config­uration
$ sudo yum install nfs-utils nfs-ut­ils-lib
also need to install nfs in the client side of the relati­onship
$ sudo systemctl enable rpcbind $ sudo systemctl start rpcbind $ sudo systemctl enable nfs-server $ sudo systemctl start nfs-server $ sudo systemctl start nfs-lock $ sudo systemctl start nfs-idma
commands to start appropiate services
$ sudo mkdir /NFSfolder $ sudo chmod –R 755 /NFSfolder
create and set up share folder
$ sudo nano /etc/fstab
open nano to edit fstab folder
172.25.22.10­:/N­FSs­har­edF­older/ /NFSfo­lder/ nfs4 defaults 0 0
add this line to the fstab folder
$ sudo mount
use this command to check what was mounted in the specified NFS server
 

File modifi­cation

chown USER FILE
changes the user ownership of a file to the specified user
chown USER: FILE
changes the user and the group to the specified user
chown USER:GROUP FILE
changes the user, and group ownership of the file to the specified user and group respec­tively
chown :GROUP FILE
changes the group ownership of the file to the specified group
chgrp GROUP FILE
changes the group ownership of the file to the specified group
chmod [0,1,2­,4,­7][­0,1­,2,­4,7­][0­,1,­2,4,7]
changes readab­ility, writab­ility, and execut­ability of a file to owner, group owner, and everyone respec­tively
chmod [u(use­r),­g(g­rou­p),­o(o­thers), a(all)­][+­,-]­[r(­rea­d),­w(w­rit­e),­x(e­xec­ute­),t­(write to not delete)] File
adds or removes permission to r,w,x from u,g,o or a

tutorial on how to setup Samba

$ sudo cp /etc/s­amb­a/s­mb.conf /etc/s­amb­a/s­mb.c­on­f.b­ackup
creates backup file in case you mess it up
sudo mkdir /Share­dFo­lder/
create folder to be shared
$ sudo chmod -R 755 /Share­dFo­lder/
set right permis­sions
$ sudo firewa­ll-cmd --perm­anent --zone­=public --add-­ser­vic­e=samba
set firewall
$ sudo firewa­ll-cmd --reload
set firewall
$ sudo nano /etc/s­amb­a/s­mb.conf
open nano to start the file config­uration
follow instru­ction in comment
then come back to this line and keep inputting the commands
$ sudo smbpasswd –a user1
set up password for user1
$ sudo systemctl enable smb.se­rvice; $ sudo systemctl enable nmb.se­rvice; $ sudo systemctl start smb.se­rvice; $ sudo systemctl start nmb.se­rvice
commands to enter testing phase
Move to the client side
and continue
smb://­ser­ver­_ip­_ad­dress
type in the server connection screen
the config­uration file should look like this:

[Shared Folder]
path = /Share­dFolder
read only = no
guest ok = yes
browsable =yes
writable = yes
create mask = 0755
directory mask = 0755
workgroup = WORKGROUP

then save and create user1.

user and groups creations and modifi­caiton

groupadd GROUP
creates new group
groupmod -n NewGro­upName
changes the group name
useradd USER
creates new user
useradd -d /path/­to/­hom­e/dir/
creates a user with specified home directory
useradd -u USERID USER
allows to create user with person­alized ID
useradd -G GROUP1, GROUP2... USER
allows to create user with multiples groups
cat /etc/p­asswd
lists all user and displays relevant inform­ation
 

most used commands

pwd
outputs the present working directory
sudo + other command(s)
allows to gain root privileges
root
access root user and its privileges
cd + specific address
access a specific address
cd
move to home directory
cd ..
go back to parent directory
ls
outputs inform­ation of present directory
ls + specific address
shows files in the specific directory
ls -a
option a allows to show hidden files
ls -l
show deeper descri­ption of showed files
ls -h
shows files in human readable format
touch "­fil­eNa­me"
creates file with the specified fileName
echo > "­insert desired text"
allows to write text to a file(if any, erase old text in file)
echo >> "­insert text here"
allows to append text to a file
cp "­fil­e" "­dir­ect­ory­"
copy files to new address
mv "­fil­e" "­dir­ect­ory­"
cut files to new address
mkdir "­nam­e"
creates a new directory inside the present directory
mkdir /path/­to/­dir­ect­ory­/"na­me"
creates directory with a specific path
rm "­fil­e"
removes files from the system
rm -r "­dir­ect­ory­"
removes recurs­ively the specified directory from the system

service related commands

journalctl
prompts the user with the active services in the system
systemctl
Control the systemd system and service manager
 

commands miscel­lanea 2

flock
manage locks from shell scripts
lockf
apply, test or remove a POSIX lock on an open file
fcntl
manipulate file descriptor
statd
NSM service daemon
stat
display file or file system status
samba
A Windows AD and SMB/CIFS fileserver for UNIX
smbpasswd
The Samba encrypted password file
sssd
System Security Services Daemon
setgid
set group identity
mktemp
create a temporary file or directory
true
do nothing, succes­sfully
false
do nothing, unsucc­ess­fully
if
"­use­" a Perl module if a condition holds
test
check file types and compare values
exit
self explan­atory
w
displays who is logged in and what are they doing
fg
brings the most recent background job to the foreground
sleep
delay for a specified amount of time
tac
concat­enate and print files in reverse
wall
write a message to all users
whatis
display basic inform­ation about a command passed as parameter
yes "­str­ing­"
infinitely outputs a string pass as parameter to the command