User Tools

Site Tools


linux:classnotes:rh124:shell

Shell

Variables

Name Function
HISTFILESIZE change the size of your histfile from default 1000 to whatever you put there
HISTTIMEFORMAT=“%F %T This add date and time details to History
export LESS=”-X“ leaves the result of cat on the screen
export EDITOR=/usr/bbin/nano change the default editor from vim to nano

Commands and Options

Command Function
grep ^[^#] this will remove the comments of a file you are viewing
!! attach the previous command usefull with sudo
sudo -i gives interactive shell similar to sudo bash

Creating dated backups

to create a new file and add a time stamp

 cp test_file backup_test_file_$(date +%F).txt 

This creates a file that looks like backup_testfile_2023-07-25.txt

=-=Tee==- The tee command tee is used to copy the output of a command and save it to a file

for example

ls -al | tee listing.txt displays the result of ls -al and creates a file listing.txt that contains the same

getent

This command is a alternative to just id

here is how to use it

[u-ansible@dubrhsatserver62 ~]$ getent passwd brindleyp@office.local
brindleyp@office.local:*:1840638513:1840600513:Philip Brindley - RDP:/home/brindleyp@office.local:/bin/bash 

as compared to

[u-ansible@dubrhsatserver62 ~]$ id brindleyp@office.local
uid=1840638513(brindleyp@office.local) gid=1840600513(domain users@office.local) groups=1840600513(domain users@office.local),1840664906(deny_user_autoenroll@office.local),1840634185(rdp_vmwareadmins@office.local),1840633304(hp blade oa administrators@office.local),1840637471(ib_ultrardps@office.local),1840653682(vmware_dmz@office.local),1840641496(sshusers@office.local),1840630206(vmware admins@office.local),1840662085(dmz universal - openshift readonly@office.local),1840662800(openshift readonly@office.local),1840634170(access_vmwaremgmtservers@office.local),1840634171(access_workstations@office.local),1840650567(dmz universal - vmware rdp@office.local)

exit codes

after you run a command you can check the exit codes by typing

 $?  
meaning
0 Command completed successfully
1 Command had an error
2 OPtion not found ie searching for text with grep

Bash Options

Use cd - to move to last working directory

linux/classnotes/rh124/shell.txt · Last modified: by 127.0.0.1