Shell commands:
$lsb_release -a = display operating system name and version
$uname -a = display all system information including: machine name, kernel name, version etc. Use it to find what kernel you're using .
$ls -sh (sh stands for sizeHumanReadble) = list files size
$ls -alx / (-alx is for AllLongUserFriendly) = list directories
$cp /home/usr/dir/{file1,file2,file3,file4} /home/usr/destination/ = copy multiple files at once
$emacs /textfile (to exit out from emacs use Ctrl+x and then Ctrl+c) = edit file
$file [path] = it shows you the type of files in that [path]
$man -k <search term> = Do a keyword search for all manual pages containing the given search term
$lscpu = lists CPU details
$lspci = lists all PCI buses and devices connected to them such as network and sound cards
$lsusb = lists all USB buses and any connected USB devices, such as printers and thumb drives
$lshal = lists all devices the hardware abstraction layer (HAL) knows about, which should be most hardware on your system
$lshw = lists hardware on your system, including maker, type, and where it is connected
$last = show you the people who have logged into the computer today and the terminals they are/were using
$free -m = shows you how much RAM memory you have free on your system
$cat example.txt | grep -v -e "Word1" -e "Word2" = exclude any lines matching two words:"Word1" and "Word2" from your search
1. $apt list --installed | grep -v automatic = list all installed packages but exclude those with word "automatic" (find only manual installed packages) $sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean = purges/completely uninstalls nodejs and clean
2. $dpkg --list = find package list that are installed into your server
$sudo apt-get remove <package-name> = uninstalls the specified package-name (software)
Install Gnome GUI for Ubuntu:
$ sudo apt purge gdm gdm3 = delete Gnome Desktop Manager
$ sudo apt install gdm3 ubuntu-desktop = install Ubuntu GUI
$ sudo systemctl restart gdm
$sudo apt install tilix = install additional terminal application for when gnome-terminal stop working (TILIX)
cURL commands:
Running curl with strace might give you a clue.
strace curl https://www.google.com |& grep open
Lots of output, but right near the end I see:
open("/etc/ssl/certs/578d5c04.0", O_RDONLY) = 4
which is where my certificates are stored.
$curl --help = curl command is a tool to download or transfer files/data from or to a server using FTP, HTTP, HTTPS, SCP, SFTP, SMB a nd other supported protocols on Linux or Unix-like system.
$cURL [options] [URL...] = [options] the curl options starting with one or two dashes; [URL...] URL of the remote server
$curl -O https://url.to.your.download.file/vue.js = saves/download the file (-O) vue.js to local drive
$curl -C -O https://url.to.your.download.file/vue.js = resume download after your connection drops
Enable timestamp for history:
HISTTIMEFORMAT="%d/%m/%y %T " # for e.g. “29/02/99 23:59:59”
HISTTIMEFORMAT="%F %T " # for e.g. “1999-02-29 23:59:59”
To make the change permanent for the current user run:
echo'HISTTIMEFORMAT="%d/%m/%y %T "'>> ~/.bashrc
# or respectively
To test the effects run:
history
https://askubuntu.com/questions/391082/how-to-see-time-stamps-in-bash-history
Mounting on a Dedicated Disk
For Sisense Linux deployments on a single node, you must mount the /opt directory on a dedicated disk. To mount an attached block device on every system reboot, add an entry for the device to the /etc/fstab file. You can use the device name, such as /dev/xvdf, in /etc/fstab, but Sisense recommends using the device's 128-bit universally unique identifier (UUID) instead. Device names can change, but the UUID persists throughout the lifetime of the partition. By using the UUID, you reduce the chances that the system becomes unbootable after a hardware reconfiguration.
To mount /opt:
1. Find the name of the device.
sudo lsblk -o
2. Format the device with the your disk name
sudo mkfs.xfs /dev/{second_disk_name}
3. Verify that the /opt directory exists.
sudo mkdir -p /opt
4. Find the UUID/ name of the device.
sudo lsblk -o +UUID
5. Openthe/etc/fstabfileusinganytexteditor.
sudo vim /etc/fstab
6. Add the following entry to /etc/fstab to mount the device at the specified mount point. The fields are the UUID value returned by blkid (or lsblk for Ubuntu 18.04), the mount point, the file system, and the recommended file system mount options.
UUID=aebf131c-6957-451e-8d34-ec978d9581ae /opt xfs defaults,nofail 0 2
Note: If you ever boot your instance without this volume attached (for example, after moving the volume to another instance), the nofail mount option enables the instance to boot even if there are errors mounting the volume. Debian derivatives, including Ubuntu versions earlier than 16.04 must also add the nobootwait mount option.
7. To verify that your entry works, run the following commands to mount all file systems
in /etc/fstab. If there are no errors, your file system will mount automatically after it is rebooted.
sudo mount -a
8. Verify that the /opt directory is mounted to the new drive and is on the new disk.
df -kh
https://documentation.sisense.com/latest/linux/linuxmount.htm#gsc.tab=0
Mount EFS to EC2 instance:
1. Install amazon-efs-utils on the EC2 instance
2. Create 'efs' folder into /var/www/finance.gigadatsolutions.com 3. Run this below command:
$sudo mount -t efs -o tls efsARN_paste_in_here:/ /var/www/subdomain.domain.com/efs
4. Test by running the command 'df -h' and by creating a folder/file
To get EFS mounted at EC2 instance boot time you have to edit /etc/fstab file like so:
sudo apt-get -y install nfs-common
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport
efsARN:/ /var/www/subdomain.domain.com/efs
3. Add this line into /etc/fstab:
efsARN.efs.us-east-2.amazonaws.com:/ /var/www/subdomain.domain.com/efs nfs defaults,_netdev 0 0
4. Test mount is right:
sudo mount -fav
Mount SMB Share to Ubuntu:
Step 1: Install the CIFS Utils pkg
sudo apt-get install cifs-utils
Step 2: Create a mount point
sudo mkdir /mnt/local_share
Step 3: Mount the volume
sudo mount -t cifs //<server_ip_address>/<remote_share> /mnt/<local_share> Or
Mounting at boot add to /etc/fstab file:
//<server_ip_address>/<remote_share> /mnt/<local_share> cifs user=<user on remote server>,pass=<passwd> 0 0
Mounting at boot under a different user:
- Create a /home/yourUsername/.smbcredentials file with username and password like so:
username=yourUsername
password=the_password
$sudo nano /etc/fstab
//<server_ip_address>/<remote_share> /mnt/<local_share> cifs credentials=/home/yourUsername/.smbcredentials,uid=fruser,gid=yourUserGroup,forceuid,forcegid 0 0
- This above command will mount the remote_share on a local_share folder that you have to initial create and set ownership and permission for 'yourUsername'.
- credentials gets the username and password from an actual file
- uid=yourUsername and gid=yourUserGroup is going to set ownership of the local_share folder to yourUsername instead of root
- forceuid and forcegid is going to force the ownership at boot time to be set to yourUsername
https://unix.stackexchange.com/questions/68079/mount-cifs-network-drive-write-permissions-and-chown
https://support.zadarastorage.com/hc/en-us/articles/213024986-How-to-Mount-a-SMB-Share-in-Ubuntu
Terminal Shortcut keys:
Ctrl+a - brings the prompt in front of your typed in word
Ctrl+e - prompt goes to the end of line
Ctrl+w - deletes the word in front of prompt
Ctrl+r fewCharactersFromEarlyCommand = this will do an”reverse search through your previous used commands in history