Linux commands
=============================
Check space
df -h
Chack folder /vat for space usage
du -h -d 1 /var/
Processeses
sudo ps aux
a = show processes for all users
u = display the process's user/owner
MATRIX
tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
tr -c "[:alpha:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
compare a remote file to local file
ssh [email protected] cat /path/to/remotefile | diff /path/to/localfile
alarm on ip adress UP
ping -I 60 -a IP_adress
SIM type
echo "You can simulate on-screen typing just like in the movies" | pv -qL 10
top 10 process sorted by memory
ps aux | sort -nk +4 | tail
network activity in real time
lsof -l
create script of last command
echo "!!" > foo.sh
show apps that use internet
lsof -P -i -n
share via 80 port
nc - v -l 80 < file.ext
copy ssh pub key to server from machine that doesn't have ssh-copy-id
cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
graph tree of sub dir
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
IP
dig +short myip.opendns.com @resolver1.opendns.com
Ip addr show
BACKUP
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
print newline, word, and byte counts for each file
Wc , wc -l lines wc -w words
&& - if that SUCSEED then do
|| - OR - either is true
=============================
lsof - ls for open files lsof /ext/dsd.sdd lsof | head lsof -p 1192
lsof -u username
Ctr+K -kill end
Ctrl Y Yank
Ctrl U beginin
Crt W word
Tail -f /pa
Less +F /path
#!/bin/bash
# sysinfo_page - A script to produce a system information HTML file
##### Constants
TITLE="System Information for $HOSTNAME" RIGHT_NOW=$(date +"%x %r %Z") TIME_STAMP="Updated on $RIGHT_NOW by $USER"
##### Functions
system_info() { echo "<h2>System release info</h2>" echo "<p>Function not yet implemented</p>"
} # end of system_info
show_uptime() { echo "<h2>System uptime</h2>" echo "<pre>" uptime echo "</pre>"
} # end of show_uptime
drive_space() { echo "<h2>Filesystem space</h2>" echo "<pre>" df echo "</pre>"
} # end of drive_space
home_space() { # Only the superuser can get this information
if [ "$(id -u)" = "0" ]; then echo "<h2>Home directory space by user</h2>" echo "<pre>" echo "Bytes Directory" du -s /home/* | sort -nr echo "</pre>" fi
} # end of home_space
##### Main
cat <<- _EOF_ <html> <head> <title>$TITLE</title> </head> <body> <h1>$TITLE</h1> <p>$TIME_STAMP</p> $(system_info) $(show_uptime) $(drive_space) $(home_space) </body> </html> _EOF_
===================
du- sh
#!/bin/bash
echo "Hello Input Folder"
read name
du -h -d 1 /$name/
sleep 5
echo "go"
======
ps axf
- process tree
PATH!
A path set in .bash_profile
will only be set in a bash login shell (bash -l
). If you put your path in .profile
it will be available to your complete desktop session. That means even metacity will use it.
For example ~/.profile
:
if [ -d "$HOME/bin" ] ; then
PATH="$PATH:$HOME/bin"
fi
Btw, you can check the PATH variable of a process by looking at its environment in /proc/[pid]/environ
(replace [pid] with the number from ps axf
). E.g. use grep -z "^PATH" /proc/[pid]/environ
Note:
bash
as a login shell doesn't parse .profile
if either .bash_profile
or .bash_login
exists. From man bash
:
it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
See the answers below for information about .pam_environment
, or .bashrc
for interactive non-login shells, or set the value globally for all users by putting a script into /etc/profile.d/
or use /etc/X11/Xsession.d/
to affect the display managers session.