Ubuntu/Commands

From r00tedvw.com wiki
Jump to: navigation, search

Commands | dig | Mail Server CLI | openssl | sed

Contents

 [hide

SCP

scp [(username@)host:filepath] [(username@)destination:file path]

spaces within files/folders can something be resolved by adding quotes around the entire value with \\ or \ followed by a space where the space exists.

i.e. scp "a@10.0.0.1:/home/folder\\ with \\ spaces/test.text" b@10.0.0.2:/home/

scp through ssh proxy

~$ scp -i ~/.ssh/id_ed25519 -o ProxyJump=user@proxyserver ./sourcefile user@destinationserver:/destinationfile

ln (symlink)

create symlink

sudo ln -s source linkname
i.e. sudo ln -s ../sites-available/helpdesk helpdesk

unlink symlink

sudo unlink link.name
i.e. sudo unlink helpdesk

send process to background

  • send command to background process, add & at the end of the command
  • CRTL+Z pauses a process
  • bg sends paused process to background
  • jobs shows processes running in the background
  • fg brings it back to the foreground

apt-get/apt-cache

apt-cache search keyword

apt-get install keyword

Update

always update the repos before installing or upgrading packages

~$ sudo apt-get update

if you wanted to update all of the packages installed on your machine, you could do this:

~$ sudo apt-get update && sudo apt-get upgrade -y

List all installed pacakges

~$ sudo apt list --installed

Search for package in the repo

~$ apt-cache search keyword

check if package is installed

dpkg -s [package]
i.e. dpkg -s apache-perl

WOL - Wake on Lan

~$sudo apt-get install etherwake
~$sudo wakeonlan MAC-Address-Here
or
~$sudo etherwake MAC-Address-Here
or
~$sudo etherwake -D MAC-Address-Here

add user

adduser [newuser]

add user to sudoer

visudo

~$ visudo
root       ALL=(ALL:ALL) ALL
newuser ALL=(ALL:ALL) ALL

add to sudo group

you may have a sudo group that you can simply add the user to.

add to the sudo group
~$ sudo usermod -a -G [group] [user]
i.e. sudo usermod -a -G sudo Joe

check to verify they are part of the group
~$ getent group sudo
sudo:x:27:Bob,Joe

check listening port

check to see if the service is running and listening on port 22

sudo egrep -i sshd /var/log/*log|more
or
sudo netstat -lp

tcpdump

check for any ssh session that is not originating from your IP

~$ sudo tcpdump -i venet0:0 port 22 and not host [your IP]

chmod

permissions

Permissions Owner Group  [Collapse Others
777 rwx rwx rwx
666 rw- rw- rw-
555 r-x r-x r-x
444 r-- r-- r--
333 -wx -wx -wx
222 -w- -w- -w-
111 --x --x --x
000 --- --- ---


wget

specify the destination file name and location

-O
example: download source.file and save it to destination.file under /home/pi/
~$ wget -O /home/pi/destination.file https://source.server/source.file


Do not check a site's certificate (valuable when downloading from a site with a self-signed cert)

--no-check-certificate


example: using pdsh, tell a bunch of computers to download file from https server and save it without checking the certificate

~$ pdsh -w ssh:pi@rpi-wb[2-24] 'wget -O /opt/vc/src/hello_pi/hello_video/20150730_1854_56.avi https://server.com/images/manual/20150730_1854_56.avi --no-check-certificate'
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki