-
-
Save idris75/1e2287330f9da971c9d6c2c77e8cbd04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env # to get all env variables | |
*********to work as root************* | |
su - | |
**************ifconfig synonyms------------ | |
ip address show or ip a s or ip a s eth0 | |
************formatted file name************ | |
cp a.txt a_$(date +%F).txt | |
#to decompress .gz file | |
gunzip *gz | |
#check services running | |
service --status-all (redhat) | |
#for one service | |
service <service-name> status/start/restart | |
sudo chmod -R ugo+rw /DATA/SHARE | |
change rwx permission types to ug[oa] | |
eg: | |
chmod a-w TEST_DEMO.java | |
chmod a+rwx TEST_DEMO.java | |
permissions given in binary: | |
4 Read, 2 Write, 1 Execute | |
eg: | |
chmod 751 TEST_DEMO.java | |
chmod 000 TEST_DEMO.java | |
Get users / cut example | |
cut -d: -f1 /etc/passwd | |
sed 's/:.*//' /etc/passwd | |
special permission: | |
s setuid/setgid permissions - appears in the read portion of user/group | |
eg: g+s | |
[ The sticky bit can be very useful in shared environment because when it has been assigned to the permissions on a directory it sets it so only file owner can rename or delete the said file.] | |
t - sticky bit - appears in the executable portion of the all users. - only file owner can rename or delete the file | |
eg: chmod +t <dir> | |
# to execute a last command: !<command>, !ls or !! | |
# to view last ls file: vi !$file | |
vi case insensitive search | |
/\c searchString | |
case sensitive search | |
/\C case sensitive search | |
# to search for a previously executed command: | |
# ctrl r and type a few letters of the command | |
# to get from history | |
history | grep <command > | |
# grep with regular expression | |
egrep "sqoop|hive" * | |
find/grep in file recursively, ignoring case, with filename, including/excluding some files | |
grep -riH --exclude "*.java" p_shipment_serial_number | |
# while using vi and get out and come back | |
ctrl z to get out, and come back to editor fg 1 or fg 2 | |
groups | |
chmod -R a+X => capital X means only the directory | |
df | |
disc usage rolled up to one level below directories | |
du --max-depth=1 | |
tail -20 <filename> | |
head -20 <filename> | |
To find in sub dir as well: | |
find . -name "*sh" | |
to find inside file: | |
grep <xxx> <filename> | |
to find files ignoring case: | |
find . -iname <filename> | |
to see running processes: | |
ps | |
ps -ef | |
kill <processId from above> | |
grep top - high usage processes | |
to see logged in users: | |
w | |
to get information from web: | |
wget | |
Calender: | |
cal | |
to see the processs: | |
ps | |
to decompress and extract files: | |
gunzip test.sh.gz | |
tar -xvzf snr_split.tar.gz' | |
to compress and zip files: | |
tar -cvzf snr_split.tar.gz ~/snr_split | |
vi search replace | |
:s/old_string/new_string | |
replaceAll: | |
:%s/old_string/new_string | |
ssh from one machine to another(from namenode to datanode) | |
ssh <servername>172.16.1.181 | |
https://youtu.be/l0QGLMwR-lY | |
to know which version we use: | |
uname | |
get ipconfig: | |
old: ifconfig | |
new: ip addr show | |
check services status, restart.... | |
old: service <name> status | |
new: systemctl | grep mysql | |
disc usage: | |
du -sh folder | |
see ports/listening tcp/udp | |
sudo netstat -tulpn | |
cpu usage of processes: | |
ps aux | grep <processname> | |
top | |
htop | |
checking mounted things: | |
mount | |
system admin commands: | |
lsof | head | |
lsof /var/log/nginx/access.log | |
lsof <processid> | grep log | |
lsof <filename> gives which processes are using the file | |
lsof -u <username> | |
lsof -i :80(port) | |
lsof -i tcp | |
---------to see class files of a jar-------- | |
jar tvf <jarfile> | |
-------------------root access ------------- | |
su - | |
ip address show or ip a s/ | |
ip r s -- ip root show | |
to get date formate = $(date + %F) | |
--------------to see ports --------------------- | |
/etc/services | |
----------create multiple folders at once--------- | |
mkdir -p hdp{1,2,3}.test.com | |
--------------run command while ssh ------------------- | |
ssh name@domain_name "df -h" to get free space |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment