Linux Basic - Hoi-Jeon/Wiki GitHub Wiki
grep
How to use grep for finding a word recursively inside the files with some specific extensions
grep -irn --include=*.{h,cpp} "Word2Find" ./
What is "Source"?
Sourcing a script will run the commands in the current shell process. Executing a script will run the commands in a new shell process. Difference between executing a script and sourcing it in Linux
Linux Screen Command
Named sessions are useful when you run multiple screen sessions. To create a named session, run the screen command with the following arguments:
screen -S session_name
You can detach from the screen session at any time by typing:
Ctrl+a d
To find the session ID list the current running screen sessions with:
screen -ls
If you want to restore screen 10835.pts-0, then type the following command:
screen -r "the session ID (e.g. 12345)"
What is /dev/null 2>&1?
- /dev/null special file. This is a Pseudo-devices special file.
- 2>&1 (Merges output from stream 2 with stream 1)Whenever you execute a program, the operating system always opens three files, standard input, standard output, and standard error as we know whenever a file is opened, the operating system (from kernel) returns a non-negative integer called a file descriptor. The file descriptor for these files are 0, 1, and 2, respectively. So 2>&1 simply says redirect standard error to standard output. What is /dev/null 2>&1?
Check if SSH is runnning
service sshd status
How to mount Samba folder with /etc/fstab
# Add in /etc/fstab
//192.168.xxx.xxx/SambaFolderNameServer /home/johndoe/SambaFolderNameClient cifs credentials=/home/johndoe/.smbcredentials,file_mode=0777,dirmode=0777,iocharset=utf8 0 0
# Remount /etc/fstab Without Reboot in Linux
sudo mount -a
How to mount Samba folder in console
# Mount
sudo mount -t cifs //192.168.xxx.xxx/SambaFolderNameServer /home/johndoe/SambaFolderNameClient -o username=johndoe,password=*****,iocharset=utf8,file_mode=0777,dir_mode=0777
# Unmount
sudo umount /home/pi/MountFolderName