Tuesday, August 1, 2023

Linux Commands

 month = $(date +%b) ; Apr

month = $(date +%B); April

yesterday = $( date -d  '-1 day' +'%Y_%m_%d') ; 2023_04_08

nth_day = $(date -d '-n day' +'%Y/%m/%d') ; 2023/04/08


network management in oracle linux 8 and later:-

Note:- It is mandatory to have GUI in case of  network restart

**restart network on oracle linux 8 and later :-
# systemctl restart NetworkManager
# nmcli networking off
# nmcli networking on


** to change file extensions in linux:
[root@localhost ~]# ls
file.txt
[root@localhost ~]# mv file{.txt,.bak}
[root@localhost ~]# ls
file.bak 


* if you want to delete all files except some use below:-
$ find . ! -name 'file_name' ! -name 'file_name' -delete



*** to find dbf files 

$ ls | grep -e "^[[:digit:]]\{4\}\+\_[[:digit:]]\{2\}\+\_[[:digit:]]\{2\}\+\_[[:digit:]]\{4\}\+\_dbf"
2023_08_13_2230_dbf_s99793_p1
2023_08_13_2230_dbf_s99794_p1
2023_08_13_2230_dbf_s99795_p1
2023_08_13_2230_dbf_s99796_p1
2023_08_13_2230_dbf_s99797_p1
2023_08_13_2230_dbf_s99798_p1
2023_08_13_2230_dbf_s99799_p1

\+\ ----> to add metacharacters like "-/_"


$ ls -lrth | awk '{print $9}' | grep -e "^[[:digit:]]\{4\}\+\_[[:digit:]]\{2\}\+\_[[:digit:]]\{2\}\+\_[[:digit:]]\{4\}\+\_[[:alpha:]]\{3\}\+\_[[:alnum:]]\{6\}\+\_[[:alnum:]]\{2\}"

2023_08_13_2230_dbf_s99798_p1
2023_08_13_2230_dbf_s99799_p1


# view selinux setting 
# sestatus 
# cat /etc/selinux/config


********************************************
Add user to sudoers list:-
( /etc/sudoers)
--------------------------------
# sudo visudo        #--------> to open /etc/sudoers in vim 
# User privilege specification
root    ALL=(ALL:ALL) ALL
<username>  ALL=(ALL:ALL)  ALL

No comments:

Post a Comment

Enable OpenSSH on Windows 11

Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...