Print current environment variables using printenv
Answer:
Besides using env command, you can also use the printenv command, which has the same effect.
# printenv
TERM=xterm
SHELL=/bin/bash
XDG_SESSION_COOKIE=ff8f5b056d8812b8...
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Print current environment variables using printenv
Answer:
Besides using env command, you can also use the printenv command, which has the same effect.
# printenv
TERM=xterm
SHELL=/bin/bash
XDG_SESSION_COOKIE=ff8f5b056d8812b8...
List 10 most often used commands
Answer:
You can list the top 10 most often used commands in your Linux, by the following method.
# history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
135 ls
63 cd
48 exit
46 sudo
34 tail
30 cat
29 df
18 date
17 vi
12 pwd
How to truncate a file?
Answer:
Assume you have a file named "test.txt", now you want to truncate (remove the content) of the file, you can use:
> test.txt
That's all.
Move a long running job to background
Answer:
Assume you have a job running for a very long time, and you might want it to run in background, even you have logged out from the SSH session.
1. Suspend it
# [Ctrl-Z]
2. Make it run in background
# bg && disown
You can now safely logout from the SSH session.
Find all files on a system larger than X MB
Answer:
To find all files on a system larger than X MB, is easy with the find command
# find / -type f -size +100M
All files larger than 100M will be returned.