Summary of useful commands
#1
How To Run sudo command With No Password
$ sudo vim /etc/sudoers
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL #Default
ubuntu ALL=(ALL) NOPASSWD:ALL #Add
Sources;
How to run sudo command with no password?
#2
Change Defalut Editor
If your defalut editor is “nano” not “vim”, you should type the command bellow;
$ sudo update-alternatives — config editorThere are 5 choices for the alternative editor (providing /usr/bin/editor).Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode #Defalut
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
3 /usr/bin/code 0 manual mode
4 /usr/bin/vim.basic 30 manual mode
* 5 /usr/bin/vim.tiny 10 manual mode #Modify
sources;
How to change visudo editor from nano to vim? [duplicate]
#3
A Shortcut To mkdir foo And Immediately cd into it like this
$ mkdir foo && cd foo$ mkdir foo; cd $_
sources;
Is there a shortcut to mkdir foo and immediately cd into it?
#4
mv all files that match specific pattern
$ find ./ -name ‘<ptn>’ | xargs -I% mv % ./<target directory>/
sources;
find で検索したファイルを一括で移動(mv)させる
#5
How To Append Current DateTime From A Variable To A Filename
#!/bin/bash
#example.sh
nowDatetime=`date ‘+%Y%m%d_%H%M%S’`;
filename=”$HOME/log/history_$nowDatetime.log”
history 10000 > $filename
sources;
Appending a current date from a variable to a filename
#6
How do I find all files containing specific text on Linux?
grep -rnw ‘/path/to/somewhere/’ -e ‘pattern’-r or -R is recursive,-n is line number, and-w stands for match the whole word.-l (lower-case L) can be added to just give the file name of matching files.
sources;
How do I find all files containing specific text on Linux?
P.S. How to display code blocks in Medium
Windows: Control + Alt + 6
Mac: Command + Option + 6
Linux: Control + Alt + 6