`
nano ~/.bashrc
pushd /var
popd //puts you back to the orginal directory
ctrl z
fg // foreground
htop // monitoring resources
sudo !! // refer to most recent command, but with sudo in front of it
Ctril u // will delete a line of text
ctrl a // front of line
ctrl e // end of line`
HISTTIMEFORMAT="%Y-%m-%d %T "
Quick Find
ls -alF ./fileName/ | grep Ab
Export a Token
echo $token | jq -R 'split(".") | select(length > 0) | .[0],.[1] | @base64d | fromjson'
Mount Setup
'sudo /usr/bin/vmhgfs-fuse .host:/ $HOME/mnt/ -o subtype=vmhgfs-fuse,allow_other'
Ubuntu VM doesn't have any networks interfaces
nmcli network on
Cat
cat > info.txt
> info.txt
cat -n info.txt
Combine lines (2 files)
a=(cat <file2.txt>))
for i in {a[$i]} "; echo {b[i]}; done;
SFTP
Have to establish and SSH connection before this
sftp [email protected]_server_ip_or_remote_hostname
get remoteFile
get remoteFile localFileNewName
get -r someDirectiory
put -r someDirectory ./' from and to
put localFile
df -h`
Tar, Encrypt and Split
tar -cvzf ../test.tgz .
tar cvaf '../folder/<file_name>' tar -czvf file.tar.gz directory tar -czvf filename.tar.gz /path/to/dir1
ls -l projects.tar.gz // Verify the Tar
tar -ztvf projects.tar.gz // List the contents
Create a tar.gz file from all pdf (".pdf") files
tar -czvf archive.tgz *.pdf
encrypt tarball
winpty openssl enc -e -aes-256-cbc -salt -in test.tar.gz -out test-encrypted.tar.gz -md sha256 winpty openssl enc -e -aes-256-cbc -salt -in test.tar.gz -out 'encrypted/test-encrypted.tar.gz' -md sha256
split encrypted tarball
split --verbose -d -b4608M 'test-encrypted.tar.gz test-encrypted.tar.gz' . // Don't forget the (.) at the end (should make a test-encrypted.tar.gz.01 and test-encrypted.tar.gz.02) note: that -b4608M argument splits into 4.5 GB chunks
combine and decrypt
cat test-encrypted.tar.gz.* > test-encrypted-combined.tar.gz
winpty openssl enc -d -aes-256-cbc -in test-encrypted-combined.tar.gz -out test-decrypted.tar.gz -md sha256
` tar -czvf <tarballname.tar.gz> src
tar -tzvf name.tar.gz // look inside
tar -xzvf ../fielname.tar.gz`
History
!<id> to rerun
Replace IP address
sed -i "s/12.33.42.7/192.168.12.120/g" .env
// Second ip for local
View IP Address
ifconfig | grep ens33 -A 1
ip a
Update Package
sudo dpkg -i linux_f5vpn.x86_64.deb
Size
du -hx --max-depth=1 .
df -hT
du -sh FILENAME
df -h
Checking Permissions
ls -al /usr/bin/sudo
ls -lah
Remove a directory
rm -r <directory name>
'rm -rf <blah'
CHOWN
sudo chown -R [email protected] folder_name
sudo chown -R drug Folder
sudo chown -R 26:26 /data/blah/foo
sudo chown -R root:root Boink
chmod +x ./script.sh // make executable
chown 1002:1002 -R $Blah
chown 1002:1002 -R /etc/app/blah
No permissions
sudo chmod 777 //*
Geneate SSH Key
ssh-keygen -t ed25519 (Hit enter for all the prompts) eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 cat ~/.ssh/id_ed25519.pub (Copy and paste the output Into Bitbucket)
Take away file permissions
chmod 755 FOLDER
Copy from Windows to Linux
scp F:/foo-data/Data/* [email protected]:~/mnt/foo-data/DD/
scp -r F:/data/blah/ [email protected]:~/mnt/data/foo/
scp -r F:/data/blah [email protected]
Copy file from Linux
scp -r [email protected]:/foo/foo2/textfile.txt /D/Global/_here/there
scp -r [email protected]:"`/foo/foo2/(parentheses) Spaces textfile.txt'" /D/Global/_here/there //note the single double quotes for spaces and parentheses when the backlash \ won't work
Copy unique
cp -u *.html destination
Download file parts and combine file back together
for i in $(seq -f "%03g" 1 26); do curl -k -u $_USER:$_TOKEN -X GET "https://blah.com/blah/file.zip.$i" -o files.zip.$i; done cat files.zip.* > files.zip
Write to a file
> datalog.txt
Append to an existing file
**>> datalog.txt // note the 2 operators **
Switch to Root
su // sudo bash // switch back 'su username'