The following command displays the status code from the last command:
echo $?
In the following command, output of a echo command is directed to standard input so that a second command viz more manages it like a file:
echo 'toto' | more -
tree --noreport .
Vi command for eliminating all occurences of colon ":" is the following:
:1,$s/://g
Here is the vi command for replacing all occurences of "old" with "new":
:1,$s/old/new/g
Vi command for searching string "xyz":
/xyz
File search:
find ./fvsa/ -name "pvsve*"
Search string 'yourDir' in dir yourdir:
grep -nr 'yourString*' yourdir
Sed is a stream editor for filtering and transforming text.
sed -i 's/word1/word2/g' inputfile
The -i option requests editing in place.
s stands for substitute. g stands for global replacement.
Memory usage:
watch -n 5 free -m
Realtime clock in a term:
watch -n 1 date
Delete 4 first characters in all file names in dir:
rename 's/.{4}(.*)/$1/' *
Delete 5 last characters in all file names in dir:
rename 's/(.*).{5}/$1/' *
Display total number of files in 'folder':
ls folder | wc -l
sudo ncdu -rx /
sudo du -shc /*
Displaying size occupied by Documents directory:
cd ~
sudo du -sh Documents
update-java-alternatives -l
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
Or in a more interactive way:
update-alternatives --config java
xrandr
xrandr --addmode HDMI-1 2560x1080
The following command starts http-server and serves all of the static content (e.g. geojson files) available in the current directory:
http-server --cors='*' -p 5252
Install pwgen package and run the following command to get a randow password with 12 characters including one special character at least:
pwgen 12 1 -y
Command to state that owner and group of directory mydir have full permission to access the directory and its content such as read, write and execute whereas others will have read and execute permission:
chmod -R 775 mydir
The following command can be use to check whether the service
management tool is service or systemctl:
ps --no-headers -o comm 1
A systemd result indicates that systemd (systemctl) is the service management tool, while
init indicates that it is System V Init (service).
sudo apt install bind9-host
host -t NS google.com
First hostname has to be configured. Display current hostname with hostnamectl.
Then configure new hostname with:
hostnamectl set-hostname muydomain.com
Verify it by running the hostnamectl command again.
Here is the link to configure postfix.
See parameters that may be configured with `mail --config-help
Now to configure them, create a file /etc/mailutils.conf if it does not already exist.
To configure for instance the domain name, complement /etc/mailutils.conf with
address {
email-domain somedomain.com;
};
Previous: Generate and deploy a Java app on the cloud with Jhipster