Difference between revisions of "Linux utils"
From Wasya Wiki
(→Create a user) |
|||
Line 6: | Line 6: | ||
=== check disks on ubuntu === | === check disks on ubuntu === | ||
sudo lsblk | sudo lsblk | ||
+ | |||
+ | === Mount a block devise === | ||
+ | |||
+ | From: https://www.digitalocean.com/community/tutorials/how-to-use-block-storage-on-digitalocean | ||
+ | |||
+ | parted /dev/disk/by-id/* mklabel gpt | ||
+ | parted -a opt /dev/disk/by-id/* mkpart primary ext4 0% 100% | ||
+ | mkfs.ext4 /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 | ||
+ | mkdir -p /mnt/volume-nyc1-01-part1 | ||
+ | '/dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 /mnt/volume-nyc1-01-part1 ext4 defaults,nofail,discard 0 2' | sudo tee -a /etc/fstab | ||
+ | mount -a | ||
+ | |||
=== check that a node is pingable in bash === | === check that a node is pingable in bash === |
Revision as of 23:48, 22 December 2016
Contents
- 1 Utils
- 1.1 Set date
- 1.2 check disks on ubuntu
- 1.3 Mount a block devise
- 1.4 check that a node is pingable in bash
- 1.5 how to tell if port 80 is listening?
- 1.6 how do I know if the system trusts the certificate?
- 1.7 how to tell if port 80 is listening? What is listening on a particular port?
- 1.8 ubuntu vpn
- 1.9 Find large files
- 1.10 see timestamps in history
- 1.11 Generate large random file
- 1.12 Add ssh key to a server
- 1.13 Add identity to a server
- 1.14 Create a user
- 1.15 Establish a simple ssh port forward
- 1.16 Reset Chef UI Password
Utils
Set date
sudo date --set "25 Sep 2013 15:00:00"
check disks on ubuntu
sudo lsblk
Mount a block devise
From: https://www.digitalocean.com/community/tutorials/how-to-use-block-storage-on-digitalocean
parted /dev/disk/by-id/* mklabel gpt parted -a opt /dev/disk/by-id/* mkpart primary ext4 0% 100% mkfs.ext4 /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 mkdir -p /mnt/volume-nyc1-01-part1 '/dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 /mnt/volume-nyc1-01-part1 ext4 defaults,nofail,discard 0 2' | sudo tee -a /etc/fstab mount -a
check that a node is pingable in bash
while ! ping -c1 bjjc_spec_22.ubuntu14 &>/dev/null; do :; done ;
how to tell if port 80 is listening?
telnet?
how do I know if the system trusts the certificate?
you use curl.
how to tell if port 80 is listening? What is listening on a particular port?
netstat -plnt
ubuntu vpn
https://hide.me/en/vpnsetup/ubuntu/openvpn/
Find large files
find / -xdev -type f -size +100M
see timestamps in history
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc ; source ~/.bashrc
Generate large random file
dd if=/dev/urandom of=/var/log/mongodb/randomFile bs=1M count=200
Add ssh key to a server
cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'
Add identity to a server
ssh-copy-id -i ~.ssh/key_name.pub user@host
Create a user
useradd? adduser?
su - <username> sudo visudo -f /etc/sudoers usernameusedforlogin ALL=(ALL) NOPASSWD:ALL sudo adduser --disabled-password <username> (and there is deluser) (I don't think I need this: usermod -aG sudo username ) - for making him a sudoer
Establish a simple ssh port forward
10.0.0.x is public, 10.0.1.x is private. Do:
sudo sysctl net.ipv4.ip_forward=1 sudo iptables -t nat -A PREROUTING -p tcp -d 10.0.0.229 --dport 2270 -j DNAT --to-destination 10.0.1.224:22 sudo iptables -t nat -A POSTROUTING -j MASQUERADE
Reset Chef UI Password
sudo -u opscode-pgsql /opt/chef-server/embedded/bin/psql opscode_chef update osc_users set hashed_password = '$2a$12$y31Wno2MKiGXS3FSgVg5UunKG48gJz0pRV//RMy1osDxVbrb0On4W' , salt ='$2a$12$y31Wno2MKiGXS3FSgVg5Uu' where username ='admin';
and login with user 'admin' and password 'password'.