ssh - is a program for logging into a remote machine and for executing
commands on a remote machine
To access remote server
$ ssh 192.168.122.50
$ ssh my.server.in
To specify a username for SSH connection
$ ssh username@hostname_or_ip
$ ssh -l username@hostname_or_ip
$ ssh -l user1(a)192.168.122.50
$ ssh -l user1(a)my.server.in
To use a different port number for ssh connection
$ ssh my.server.in -p 2222
$ ssh 192.168.122.50 -p 2222
To run a command on a remote server from a local computer
$ ssh 192.168.122.50 rm ~/Desktop/test_file.txt
To execute multiple commands using SSH on remote nodes
$ ssh 192.168.122.50 command1; command2; command3
To make ssh to use protocol version 2
$ ssh -2 user1(a)192.168.122.50
To Print debug information
$ ssh -v user1(a)192.168.122.50
To increase the level of verbosity
$ ssh -vv user1(a)192.168.122.50
To get more level of verbosity
$ ssh -vvv user1(a)192.168.122.50
To enable X11 forwarding with ssh command
$ ssh -X ip_address
$ ssh -X 192.168.122.50
To hide the error message
$ ssh -q 192.168.122.50
To change any default value to other possible values during ssh
$ ssh -o option=value ip_address
$ ssh -o Port=2222 192.168.122.50
regards,
T.Dhanasekar
ss - is used to dump socket statistics, and to investigate sockets
To list all Connections
$ ss
To list Listening and Non-listening Ports
$ ss -a
To list Listening Sockets
$ ss -l
To list all TCP connections
$ ss -t
To list all listening TCP connections
$ ss -lt
To list all UDP connections
$ ss -ua
To list all listening UDP connections
$ ss -lu
To display PID of sockets
$ ss -p
To display summary statistics
$ ss -s
To display IPv4 and IPv6 socket connections
$ ss -4
$ ss -6
To filter connections by port number
$ ss -at '( dport = :22 or sport = :22 )'
$ ss -at '( dport = :80 or sport = :80 )'
$ ss -at '( dport = :ssh or sport = :ssh )'
$ ss -at '( dport = :http or sport = :http )'
regards,
T.Dhanasekar
Hi Mr Dhanasekar
Nice to e-meet
Are these items of use
I have found 1 man who is gifting them!
@ , motherboard,
cooler,
RAM
, graphics cards
, laptop PSU,
5v 9v 12v power bricks,
modem
What can we use these for ?
Kind regards
@ ukX
Peter Regelous
split - is used to split large files into smaller files
syntax
$ split {options} {file_name} {prefix}
$ cat example.txt
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
This is line 10
To split example.txt with verbose option
$ split example.txt --verbose
To split files with customize line numbers
$ split -l5 example.txt --verbose
To split files with file size
$ split -b 4 example.txt --verbose (in bytes)
$ split -b 2K <file_name> --verbose (in Kb)
$ split -b 2M <file_name> --verbose (in Mb)
$ split -b 1G <file_name> --verbose (in Gb)
To create Split files with numeric suffix instead of alphabetic
$ split -d example.txt --verbose
x00
To split file with customize suffix
$ split -l5 example.txt ilugc_file
To generate n chunks output files
$ split -n5 <file_name>
To Prevent Zero Size Split output files
$ split -n60 -e example.txt
To create split output files of customize suffix length
$ split -b 4 example.txt -a 3
$ split -b 4 example.txt -a 4
To split ISO file and merge it into a single file
$ split -n5 ubuntu-22.04.iso Split_IS0_
it will split ISO file into 5 pieces
To merge these files into a single
$ cat Split_IS0_a* > ubuntu22.04_new.iso
To verify the integrity of merge file using md5sum
before split of iso
$ md5sum ubuntu22.04.iso
after split and merge
$ md5sum ubuntu22.04_new.iso
regards,
T.Dhanasekar
source - is a built-in shell command that reads and executes the file
content in the current shell.
syntax
$ source [filename] [arguments]
To pass commands and arguments
$ cat example.txt
free -h
pwd
date
time
uptime
$ source example.txt
To read variables from a file
$ cat example.sh
#!/bin/bash
VAR1="a"
VAR2="b"
VAR3="c"
create bash script
$ cat sample.sh
#!/bin/bash
source example.sh
echo "VAR1 is $VAR1"
echo "VAR2 is $VAR2"
echo "VAR3 is $VAR3"
$ source sample.sh
To refresh the current shell environment
$ alias ll = 'ls -l'
$ alias c = 'clear'
$ c
$ ll
This command only works in the current shell session
To make it permanent
$ sudo nano ~/.bashrc
alias ll = 'ls -l'
alias c = 'clear'
:x
Refresh the current shell environment and make it permanent for the user
$ source ~/.bashrc
To make it system wide change
$ sudo vim /etc/profile
alias ll = 'ls -l'
alias c = 'clear'
:x
# source /etc/profile
regards,
T.Dhanasekar
sort - is used to sort a file, arranging the records in a particular order.
$ cat file.txt
assam
tamilnadu
chattisgarh
delhi
gujarat
himachal pradesh
kerala
bihar
To sort arrange the file.txt
$ sort file.txt
To Save Output to File
$ sort file.txt > sorted.txt
To Check for Sorting in File
$ sort -c file.txt
To Sort Multiple Files
$ sort file1.txt file2.txt
To Sort in Reverse Order
$ sort -r file.txt
To Remove Duplicate Entries
$ sort -u file.txt
To Sort by Months
$ ls -l > month.txt
$ sort -Mk6 month.txt
To Randomly Sort Data
$ sort -R sorted.txt
regards,
T.Dhanasekar
snap - is used to install, configure, refresh and remove snaps
$ sudo snap install snap-store
To Install Snap Apps
$ sudo snap install <package_name>
To list Installed snaps
$ snap list
To Search for Snaps
$ snap find <search_term>
To update snaps
$ snap refresh <package_name>
To print which snap packages have available updates
$ sudo snap refresh --list
To downgrade Snaps
$ sudo snap revert <package_name>
To remove Snaps
$ sudo snap remove <package_name>
To remove a snap without generating a snapshot
$ sudo snap remove <package_name> --purge
To Disable Snaps
$ sudo snap disable <package_name>
To Enable a disabled snap
$ sudo snap enable <package_name>
To List All Running Services
$ snap services
To list the services of a single snap
$ snap services <package_name>
To Start, Restart, and Stop Snap Services
$ sudo snap restart <package_name>
$ sudo snap start <service_name>
$ sudo snap stop <package_name>
To prevent a snap service from starting on boot
$ sudo snap stop --disable <service_name>
To make a service to start on next boot
$ sudo snap start --enable <service_name>
To Download and Install Snap Apps Offline
$ snap download <package_name>
To display history of changes made to system
$ snap changes
To change to a different channel
$ sudo snap refresh <package_name> --channel=<channel_name>
$ sudo snap refresh youtube-dl --channel=stable
regards,
T.Dhanasekar
slogin - is an alias for the ssh client, which is used to connect securely
to a remote shell.
To login to a remote server
$ slogin 192.168.122.50
$ slogin user1(a)192.168.122.50
To login to remote server with port
$ slogin -p 22 user1(a)192.168.122.50
To to login as user1 on the remote machine
$ slogin -l user1 192.168.122.50
regards,
T.Dhanasekar
sleep - is used to delay for a fixed amount of time during the execution of
any script
syntax
$ sleep number[suffix]
To make sleep command without any suffix
$ sleep 20s
To display help options
$ sleep --help
$ cat sleep.sh
#!/bin/bash
echo "Waiting for 10 seconds..."
sleep 10
echo "Task Completed"
:x
$ sh sleep.sh
Waiting for 10 seconds...
Task Completed
sleep command in the terminal with other commands
$ ll && sleep 20 && pwd && free -h
regards,
T.Dhanasekar
skill - is used to send signals to users and process
To halt/stop user1
$ skill -STOP -u user1
To resume already halted user1
$ skill -CONT -u user1
To kill and logout user1
$ skill -KILL -u user1
To kill and logout all users
$ skill -KILL -v /dev/pts/*
To stop 3 users user1, user2, user3
$ skill -STOP user1 user2 user3
regards,
T.Dhanasekar
size - list section sizes and total size of binary files
$ cat hello.c
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
$ gcc hello.c -o hello.o
$ size hello.o
To display in octal
$ size -o hello.o
To display in hexadecimal
$ size -x hello.o
To display in system V format and hexadecimal values
$ size -Ax hello.o
regards,
T.Dhanasekar
shutdown - is used to shutdown the system in a safe way
syntax
$ shutdown [OPTIONS] [TIME] [MESSAGE]
To shutdown the system at a specified time 6 P.M
$ sudo shutdown 18:00
To schedule a system shutdown in 30 minutes from now
$ sudo shutdown +30
To shutdown the system immediately
$ sudo shutdown now
To shutdown the system in 30 minutes from now and notify the users with
message “system upgrade”
$ sudo shutdown +30 "system upgrade"
To halt your system
$ sudo shutdown -H
To make shutdown power-off machine
$ sudo shutdown -P
To reboot using shutdown
$ sudo shutdown -r
To specify a time argument and a custom message
$ sudo shutdown -r +10 "system upgrade"
To cancel a scheduled shutdown
$ sudo shutdown -c
To cancel a scheduled shutdown, and to broadcast a message to all users
$ sudo shutdown -c "reboot is cancelled"
regards,
T.Dhanasekar
showkey - examine the codes sent by the keyboard
To examine the codes sent by the keyboard
$ sudo showkey
To display print options
$ sudo showkey -h
To start showkey in scan code dump mode
$ sudo showkey -s
To start showkey in keycode dump mode
$ sudo showkey -k
To start showkey in `ascii‘ dump mode.
$ sudo showkey -a
regards,
T.Dhanasekar
shuf - writes a random permutation of the input lines to standard output
shuf command without any option
$ shuf
1
2
3
ctrl+d
3
1
2
$ cat file.txt
msg1
msg2
msg3
msg4
msg5
msg6
To shuffle all the lines in the file
$ shuf file.txt
To add the number of lines to shuffle
$ shuf -n 3 file.txt
To make shuf as a range
$ shuf -i 10-30
To get only one output from the randomized range
$ shuf -i 10-100 -n 1
To shuffle a range and allow displaying three outputs which can be
repetitive.
$ shuf -i 10-100 -n 3 -r
To use shuf as a List
$ shuf -e a b c d
$ shuf -e 1 2 3 4
To randomize a list and decide to only output two output lines
$ shuf -e -n 2 1 2 3 4
$ shuf -e -n 2 a b c d
To write output to a file
$ shuf -i 10-20 -o file.txt
$ cat file.txt
regards,
T.Dhanasekar
shred - overwrite a file to hide its contents, and optionally delete it
syntax
$ shred [filename]
$ shred sample.txt
To designate number of times to overwrite a file
$ shred -n 2 example.txt
To overwrite and delete a file
$ shred -uv sample1.txt
To selectively overwrite bytes of text
$ shred -s [number_of_bytes] [filename]
$ shred -s 10 password.txt
To run shred with verbose mode
$ shred -v file.txt
To change permissions to allow writing if necessary
$ shred -f [filename]
$ shred -f file.txt
To hide shredding from the file system.
$ shred -z filename
$ shred -z file.txt
To Display shred Basic Details and Version and help options
$ shred --version
$ shred --help
regards,
T.Dhanasekar
shasum - Print or Check SHA Checksums
syntax
$ shasum [OPTION]... [FILE]...
$ cat sha_example.txt
This is test message for shasum
$ shasum sha_example.txt
$ sha1sum sha_example.txt
$ sha256sum sha_example.txt
or
$ shasum -a 256 sha_example.txt
$ sha512sum sha_example.txt
To generate the SHA value for text on the console
$ sha256sum -t
This is test message (Enter)
Ctrl+d
regards,
T.Dhanasekar
sha1sum - compute and check SHA1 message digest
syntax
$ sha1sum [OPTION] [FILE_NAME]
To create the SHA-1 of a file
$ sha1sum example.txt
To create the SHA-256 of a file
$ sha256sum example.txt
To write the SHA-1 of a file to a file
$ sha1sum example.txt > example.sha1
add some contents to example.txt
and check with
$ sha1sum -c example.sha1
example.txt: FAILED
sha1sum: WARNING: 1 computed checksum did NOT match
updated the SHA-1 file against the example.txt
$ sha1sum new.txt > example.sha1
$ sha1sum -c example.sha1
example.txt: OK
To forcefully change the command’s capabilities to read in binary mode
$ sha1sum -b example.sha1
To print help commands
$ sha1sum - -help
To get a list of other sha-related commands
$ sha
regards,
T.Dhanasekar
sh - is a command language interpreter that executes commands read from a
command line string, the standard input, or a specified file.
To Invoke the Bourne shell
$ sh
To run the bash script
$ sh example.sh
regards,
T.Dhanasekar
sg - execute command as different group ID
To execute command as different group ID
$ sg group-name -c 'command'
$ sg dev-group -c 'sleep 100'
$ sg admin-group -c 'ping 8.8.8.8'
regards,
T.Dhanasekar
sftp - is a secure remote file transfer utility based on File Transfer
Protocol (FTP)
To Connect to SFTP
$ sftp user(a)192.168.122.50
sftp>
To get help commands
sftp> help
To Check Present Working Directory
local working directory
sftp> lpwd
remote working directory
sftp> pwd
To List files with sftp
On Remote
sftp> ls
On local machine
sftp> lls
To upload file using sftp
sftp > put sample.py
To upload multiple files using sftp
sftp > mput *.py
To download files using sftp
sftp > get example.py
To download multiple files using sftp
sftp > mget *.pl
To switching directories in sftp
On Remote
sftp > cd Documents
on local machine
sftp > lcd Documents
To create new directory on local
sftp > mkdir local_dir
To create new directory on remote
sftp > lmkdir remote_dir
To remove directories using sftp
sftp > rm file.txt
sftp> rmdir dir1
To exit sftp shell
sftp > exit
regards,
T.Dhanasekar
sfdisk - display or manipulate a disk partition table
To display partitions of all the disks in system
$ sudo sfdisk -l
To view disk partitions of a specific device
$ sudo sfdisk -l /dev/vda
To display Total Partition Size
$ sudo sfdisk -s
To display Partition size of specific partition
$ sudo sfdisk -s /dev/vda
To dump disk partition details to text file
$ sudo sfdisk -d /dev/vda > vda.out
To display Disk Geometry for Debugging
$ sudo sfdisk -G
To display the kernel’s idea of the geometry of the device
$ sudo sfdisk -g
To display All Disk Partition types
$ sudo sfdisk -T
To display the partition type of a specific partition
$ sudo sfdisk --print-id /dev/vda 1
regards,
T.Dhanasekar
setsid - run a program in a new session
syntax
$ setsid [options] program [arguments]
$ cat add.sh
#!/bin/bash
# Take input from user and calculate sum.
read -p "Enter first number: " num1
read -p "Enter second number: " num2
sum=$(( $num1 + $num2 ))
echo "Sum is: $sum"
:x
To execute shell script in a new session.
$ sudo setsid ./add.sh
To set the controlling terminal to the current one.
$ sudo setsid -c ./add.sh
To wait for the execution of the program to end, and return the
exit value of this program as the return value of setsid
$ setsid -w ./add.sh
regards,
T.Dhanasekar
setfacl - set file access control lists
syntax
$ setfacl option file
To modify ACLs of file to give read and write permission to user1
$ setfacl -m u:user1 rw file
To remove all extended ACL entries
$ setfacl -b file.txt
To remove entries from the ACL of file, To remove group 'ilugc' from a
file's ACL
$ setfacl -x g:ilugc file.txt
To remove the default ACL
$ setfacl -k file
To apply operations to all files and directories recursively
$ setfacl -m g:ilugc:rw -R directory
To restore a permission backup
$ setfacl --restore=file
To copy the ACL of one file to another
$ getfacl example.txt | setfacl --set-file=- f sample.txt
regards,
T.Dhanasekar