FreeBSD Commands:
default
Apply Security Patches
----------------------
freebsd-update fetch
freebsd-update install
Then run both these commands, if they differ, need to reboot:
freebsd-version -k; uname -r
Example of them differing:
13.1-RELEASE-p3
13.1-RELEASE-p2
Also, if any patches were applied to running binaries on system,
they need to be restarted.
update freebsd ports
--------------------
*** if first time using portsnap use:
portsnap fetch extract update
else use:
portsnap fetch update
pkgdb -u
pkgdb -F
Update and upgrade freebsd ports, portugrade must be
installed to use pkgdb, may have to type: rehash after
installing portugrade if using default shell (csh) as root
**pkgdb -u = update or create pkg database file 'pkgdb.db'
**pkgdb -F = interactively fix package registry database
Freebsd Branches (version controlled)
----------------
branches are in constend development, releases are snapshots of branches
-stable # production version, as in codebase doesn't have major changes to it
-release # only gets major bugfixes
-testing # only after tested, with no major issues, new features are added
-current # development version, new versions of packages enter here,
# new developments and features are developed here
pkg_version -vl '<'
Shows which ports need to be updated.
/usr/ports/UPDATING
***ALWAYS!*** read this file before blindly updating
you ports! Follow it's recommedations.
You can use something like this for a quick look:
grep -B 1 AFFECTS: /usr/ports/UPDATING | head -20
pkgdb -L
portupgrade -R python27
To update a single port, may be better to do
this for each port. You can also specify more
than one port:
portupgrade thisport andthisport andthatport
-R = updgrade dependencies first
portupgrade -a
If you are lazy you can update them all
pkgdb -fu
If database is corrupted use this.
** -fu force update regardless of timestamps
portupgrade -af
You could use this to force an upgrade even if
downgrading/reinstalling or held in HOLD_PKGS
in pkgtools.conf. It forces all packages to be
upgraded whether they are up to date or not.
So it will take some time.
** -a = all
** -f = force
end update freebsd ports
------------------------
cd /usr/ports/chosen/port
all-depends-list
build-depends-list
run-depends-list
package-depends-list
pretty-print-build-depends-list
pretty-print-run-depends-list
Find out what dependencies a port needs
make WITHOUT_X11=yes all-depends-list
You can also test different build scenarios.
other ways to update ports
---------------------------
portsnap fetch update
pkgdb -F
portsdb -Uu
updates version info in ports database
this needs to be ran after cvsup or csup
make fetchindex
portsdb -u
portversion -l "<"
portupgrade -arR
run this to update with portupgrade
portversion | grep "<"
list packages that are out of date
portupgrade -a
pkgdb -F
portupgrade -a
Updates ports that are installed
portsdb -Fu
fetch INDEX and rebuild portsdb
portmaster -a
Updated ports that are installed
------------
---------
error when installing portsnap:
Warning: Object directory not changed from original
had to go into some of the subdirectories and do a:
make obj
---------
portupgrade package-name
update specific port
portversion -l '<'
list outdated ports
cvsup /root/ports-supfile
update ports tree with created file
end other ways to update freebsd ports
--------------------------------------
make config
make config file (can be done after install to reconfigure options)
make deinstall
make install APR_UTIL_WITH_BERKELEY_DB=yes
fix an error for a dependency option
make index
/usr/ports updates index
make readmes
creates readmes /usr/ports
cd /usr/ports
make search name=pptp
search ports by name
cd /usr/ports
make search key=pptp
searches ports for keyword
freebsd package manager (use ports or pkg not both, so stick with one)
----------------------------------------------------------------------
pkg_info
show packages installed
ls /var/db/pkg
show packages installed
pkg_info -R apache-1.3.37_2
show dependencies of apache
pkg_fetch nagios-3.0.3
fetches a port
pkg_version
show versions of packages installed vs available via ports
pkg_deinstall packageName
remove package
pkg_add name.tar.gz
adds package from ports ??
pkg_add -r name
downloads package and then adds it
pkg_info -IX font
show installed fonts
end pkg info
------------
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.3/packages/i386/filename.tgz
adds package openBSD
env
print environment variables
locale -a
print names of all available locales
cntrl - i
equivalent to tab
xset b off
turn off system beep in X
sysctl hw.syscons.bell=0
turn off beep globally until a reboot
hw.syscons.bell=0
add this line to /etc/sysctl.conf, turns off system beep globally for good
sysctl hw.acpi.battery
Show info about battery
sysctl -a | grep -i memory
show memory stats
(sysctl hw.acpi.battery.life|cut -d "," -f2|cut -d "%" -f1|cut -d " " -f2)
show battery juice
du -h -d 1
disk usage of directories
du -sh
disk usage of directory and files
du -x
tells what is using space
du -sk *
show disk usage
for each in `ls -1`;do du -sh $each;done
show file size of each folder in current directory
tar -zcvf newArchive.tar /folderToCompress
tar a folder
tar -zxf newArchive.tar -C /tmp
extract folder to tmp directory
tar -cjvf www042309.tar.bz2 ./www
backup website -j for bz2
tar -xjf www042309.tar.bz2
untar website
tar -jxvf file.tar.bz2
untar bz2
tar -zxvf file.tar.gz
untar gz
tar -xvzf file.tar.gz -C directory
untar specific directory
tar -xzvf phpMyAdmin_x.x.x.tar.gz
tar -z auto recognize gzip
(cd /home/username/lrn && tar cf - . ) | (cd /mnt/usb && tar xBf -)
or
tar cf - ./lrn | (cd /mnt/usb; tar xf -)
copy files from one directory to another including symlinks
(cd /home/username/lrn && tar cf - . ) | "(cd /mnt/usb/ && tar xvpf -)"
remotely copy files from one directory to another including symlinks
cd ..
go up one directory
cd ~
or
cd
go to home directory
cd -
go to last directory you were in
echo $OLDPWD ,will show where this will take you
mount -t msdosfs /dev/da0s1 /mnt/usb
mount usb drive
umount /mnt/usb
unmount disk
mount -t cd9660 /dev/acd0 /mnt/dvd
mount dvd
umount /mnt/dvd
unmount dvd
mdconfig -a -t vnode -f /path/to/image.iso -u 1
mount -t cd9660 /dev/md1 /mnt/cdrom
mount -t msdos /dev/nc0c /cdrom
creates virtual cdrom drive and mounts it
mount -u /mnt/cdrom
mdconfig -d -u 1
unmounts and undoes virtual drive
mount -a -t ufs
mount file systems read/write ??
mkdir /data
vi /etc/fstab
/dev/ada1s1d /data ufs rw 2 2
Add an already formatted hard drive partition. Ex: Stick an
old fbsd hard drive in machine and access with current fbsd
install.
camcontrol devlist
list usb devices
fusepod
ipod program
camcontrol eject 1:0:0
ejects ipod
xev
this will capture keypress events and give the names of the keys
last
shows who logged in and when
last -20
show last 20 logins
last username
indicate last logins of users and ttys
ndisgen
generate a FreeBSD driver module from a Windows(R) NDIS driver distribution
ndiscvt -i bcmwl5.inf -s bcmwl5.sys -o ndis_driver_data.h
convert Windows(R) NDIS drivers for use with FreeBsd, (broadcom ethernet)
kldload ./bcmwl5_sys.ko
load linksys ndisDriver
kldstat
shows custom loaded kernel modules
pciconf
diagnostic utility for the pci bus
ifconfig bge0 down
disable network card bge0
killall -SIGUSR1 conky
restart conky
aterm -e hw.acpi.battery
open aterm and execute command
more /etc/group
show all groups
xmodmap
utility for modifying keymaps and pointer button mappings in X
rehash
only when using sh. tells system about newly installed programs
iconv
character set conversion
ndisgen
generate a FreeBSD driver module from a Windows(R) NDIS driver distribution
wicontrol
configure Lucent, Intersil, and Atheros wireless devices
pciconf -lv
diagnostics utility for the PCI bus
fstat
identify active files
smb://domain\user@computerName/C$
jobs
listjobs
bg programName
send program to background
^Z
suspend current job
fg
bring job/program to foreground
sftp -oPort=22222 user@ip-address
sftp to port 2222
fbsetroot -solid black
set fluxbox background to black
session.screen0.rootCommand: fbsetbg ~/background/ricci.jpg
set backgorund in fluxbox
ps -aux
list running processes
Mysql
-----
add mysql_enable="YES" to /etc/rc.conf
start mysql on boot
/usr/local/etc/rc.d/mysql-server start
/usr/local/etc/rc.d/mysql-server stop
start and stop mysql, if mysql_enbale="YES" is added to rc.conf
cat /usr/local/etc/rc.d/mysql-server to see script that is being called
mysql-backups
+--------------
mysqldump -uroot -p --all-databases > /bkup/path/all-dbs.sql
backup all databases
mysqldump -uuser -p db-name > /bkup/path/db-name.sql
backup single database
mysqldump -uroot -p db-name tbl-name > /bkup/path/db-name-tbl-name.sql
backup table
end-mysql-backups
----------------+
mysql-restores
+------------
cat all-dbs.sql | grep -i 'create database'
A dump of all databases has the CREATE DATABASE commands in it.
So you should not have to create a databases first
mysql -uroot -p < /bkup/path/all-dbs.sql
restore all databases
cat all-dbs.sql | grep -i 'create database'
A single database dump does not have the CREATE DATABASE command
So you may have to create the database before importing:
mysql -u root -p
mysql> CREATE DATABASE dbName;
mysql> exit
mysql -u root -p -D chosenDatabase < dbname-bkup.sql
import single database file
mysql -uusername -D chosenDatabase -o < all-dbs.sql
Only restores the chosenDatabase from a backup of all databases
You may have to create at least one empty database for this to work.
cat all-databases.sql | sed -n -e '/^-- Current Database: `chosenDatabase`/,/^-- Current Database: / p' | sed -e '$d'
Sed out just one database from a file containing all databases. You may want to pipe this to mysql or redirect to file
or even indirect to mysql.
There is also some data at the top and bottom of a dump, if you need this you may want to head and tail it:
To see line numbers for easy counting of needed lines for head and tail:
less -N all-databases.sql
head -n 15 all-databases.sql > chosen-database.sql
cat all-databases.sql | sed -n -e '/^-- Current Database: `chosenDatabase`/,/^-- Current Database: / p' | sed -e '$d' >> chosen-database.sql
tail -n 9 all-databases.sql >> chosen-database.sql
cat chosen-databases.sql
Cat or less new.sql to make sure it looks descent, then import/restore the file.(example above)
sed -n '/^-- Current Database: `chosenDb`/,/^-- Current Database: `/p' allDbs.sql | sed -n '/^CREATE TABLE `chosenTable`/,/^DROP TABLE /p' > dbname.chosenTable.sql
Restore a table by extracting it from a file dump of all databases
Sed can read a file so no need to cat pipe like above
+-
mysqlimport is another tool for importing data:
mysql -uroot -p -e 'CREATE DATABASE oses'
create database oses from shell
mysql -uroot -p -e 'CREATE TABLE oses(id INT, osName VARCHAR(30), osDescription VARCHAR(60))' test
Create a table called oses in the test database
-e = executes a statement and quits, so mysql can be jacked with from the command line
mysql -uroot -p -e 'DESCRIBE oses' test
The paranoid could make sure it is as it is...
mysql -uroot -p -e 'CREATE TABLE oses(id INT, osName VARCHAR(30), osDescription VARCHAR(60))' test; mysql -uroot -p -e 'DESCRIBE oses' test
Both those could have been done in one command
ed
a
01 FreeBSD Primary Desktop and Server
02 Arch Secondary OS
03 NetBSD Proxy Server
04 Debian Sandbox
05 OpenBSD Firewall
06 Windows 2008 Server Tertiary OS
07 Plan 9 Research Box
08 MenuetOS 64Bit ASM Study Box
09 Windows 98 Old School RCE Box
10 Windows XP RCE Box
11 Windows 7 Game Box
12 Inferno Secondary Research Box
.
w oses.txt
q
Use ed to create a tab delimited file to mysqlimport into mysql. (2 tabs per line 1 inbetween each field)
No reason to have an editor war when you can ride a dinoseditor
ed = start ed (edit text) line editor
a = append text to buffer (and enters input mode)
. = exit to command mode (if in inupt mode, else prints current line in buffer, also matches single character in regex)
w = write to file
q = quit
od -c oses.txt
make sure file is tab delimited correctly
-c = print output in C-style escaped characters (Ex: \t for tab)
cat -t oses.txt
make sure file is tab delimited correctly (incase you prefer a kitty, over od)
-t = show tabs as ^I (displays non-printing characters)
od oses.txt
If you prefer hex mode
By the way od = octal, decimal, hex, ASCII dump
mysqlimport -uroot -p --local test oses.txt
-u = user to import data with
-p = password (prompts for password, prefered method)
-pMyPassword (does not prompt for password, and now it can be viewed in history)
--local = read input files locally (same as -L)
test = database importing to
oses.txt = table importing to (mysqlimport strips the extention off and imports to table oses, in this case .txt)
mysql -uroot -p -e 'SELECT * FROM oses' test
Display everything imported into table oses inside the database test
-+
end-mysql-restores
-----------------+
--
mysqladmin shutdown
--
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h ishbsd.houston.rr.com password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local ; /usr/local/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/local/bin/mysqlbug script!
+++++++++
end-mysql
--------
roxFiler
--------
~/.config/rox.sourceforge.net/Templates
Adds to rightClick new
/home/username/.config/rox.sourceforge.net/SendTo
Adds to sendTo
end roxFiler
------------
dmesg | grep -i memory
show total and available mem
#ls
man page of ls in konqueror
/etc/rc.d/sshd restart
restart ssh (can also use start,stop, forcestop,etc
sed -i.bak s/e/o/g foo
replace every "e" with "o" in file foo (makes a backup)
sed -i '' s/e/o/g foo
does not make a backup
htpasswd .pwdFile userName
change password or add user "-c to create file"
pw user mod lust -G wheel
add lust to wheel group
whereis pptp
echo /usr/ports/*/*pptp*
alternate ways to find a port
whereis programName
display one or more mathces of program you are looking for
which bash
will show which bash will be called first
locate aProgramName
display every file that matches a programs name
kill -9 #####
force kill
aterm -bl
borderless
visudo
edit /etc/sudoers (usage: visudo)
sudo crontab -e
edit current crontab
config.log
after running ./configure log is stored in same folder
ls -I
**Note** That is a capital: i
Prevent hidden files from being shown. The ones starting with a dot: .tmux.conf
Suppress the -A that super-user automatically has set on FreeBSD... old root,
when using: ls
ls -R / | more (use less on linux)
show all directories on system
ls -alAR
recursively list directories, including .directories
ls -G
show file, folder, executables in color
dig -x 192.168.3.3
find hostname by address
tail -100 filename
view last 100 lines of a file
head filename
view first 10 lines of a file
vpnc --debug 99 --enable-1des --dpd-idle 0
vpnc with debug options all the way and weak encryption set no idle
vpnc-disconnect
disconnect vpnc
wget -r -l1 -H -t1 -nd -N -np -A.png,.jpg,.gif -erobots=off -i ~/getPics.txt
-r -H -l1 -np = recursive download, span domain, one level, no parent.
-A = attributes
-N = turns on timestamping so same files are not downloaded
-nd = puts everything in one directory rather than sites directories
-erobots.txt = igonre robots.txt
-i /fileName = lets you put urls inside text file
wget -mirror -w3 -p htt://www.whatever.com
-w = wait
-p = get all required elements (useful with mirror)
wget -i file-with-links.txt
download links in a file
dmesg | grep ndis
scrub dmesg for ndis info
ifconfig | ndis0
shows status of ndis ip
ifconfig ndis0 inet 192.168.3.70 netmask 255.255.255.0 ssid joetest wepkey 0x43DB5804CD weptxkey 1 wepmode on
connects wpcg54g to wlan with wep (weptxkey 1 picks first wep key)
ifconfig ndis0 up scan
scans for wireless access points
gdb /usr/local/bin/beaver/beaver.core
shows core dump of beaver with gdb
df
show partitions
uptime
show how long its been since a reboot
w
show who is logged in, from where, and what they are running
who
show who is logged int
finger
displays other users logged in system
last
last users logged in
ac
show how long you have been logged in.. in total
top
shows what's running
ps -aux
shows what is running in detail
uname -a
shows system information
uname -mrs
show current version
netstat
displays current network connections
netstat -an
display current connections, source, destination and ports
netstat -rn
display routing table for ips bound to server
hostname
shows hostname
aterm -sl 32000
saveline buffer 32000 lines
ls -1 | wc -l
count files in a directory
awk 'sub("$", "\r")' unixfile.txt > winfile.txt
convert file from unix to windows
awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt
convert file from windows to unix
tr -d '\15\32' < winfile.txt > unixfile.txt
remove carraige return and ^Z's from a file
perl -p -e 's/\r$//' < winfile.txt > unixfile.txt
convert win file to unix
perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt
convert unix file to win
set -o vi
set ksh to vi mode
shift + insert
paste what mouse has copied
cal
shows calendar of this month
rdesktop -f
fullscreen rdesktop
rdesktop -g 1024x768 servername
set geometry of rdesktop
man 3 printf
shows section 3 of printf (3 seems to be summary????)
mixer
shows current volume settings
mixer vol 95:95
mixer pcm 95:95
mixer speaker 95:95
mixer -s vol 10
change volume
date 1404160300
Sets date to: Wed Apr 16 03:00 CDT 2014
date 1404160300.30
Sets date to: Wed Apr 16 03:00:30 CDT 2014
Also set seconds using .
date yymmddHHMMss
yy = two digit year
mm = month
dd = day
HH = hours [0..23]
MM = minutes
ss = seconds
date 1830
Change time to 6:30 without modifying the date.
date +"%T %p"
shows date with am/pm
history
shows history of commands
cat .bash_history | grep ssh
list history matches to ssh
cat > cat.txt
create file cat.txt and input text, ^D to get out and write file
cat < cat.txt
same as cat cat.txt, reads file
cat < cat.txt > newCat.txt
cp contents of cat.txt to newCat.txt
cat cat.txt newCat.txt > bigCat.txt
copy contents of cat.txt and newCat.txt into bigCat.txt
----
bash
cntrl-r
search bash history
cntrl-w
delete word backwards
cntrl-k
delete rest of line forward
cntrl-d
delete char under cursor
alt-d
delete word forward
cntrl-a
cursor to beginning of line
cntrl-e
cursor to end of line
alt-f
one word forward
alt-b
one word back
cntrl-l
clears screen
alt-l
lowercase current word
alt-u
uppercase current word
PROMPT_COMMAND='history -a && history -n'
collects history from current open terminals
cp ./test.txt{,.bak}
copies test.txt to test.txt.bak
cp -a ./directory/* /anotherDirectory/
copies all files in a folder and keeps permissions
echo $_
echos last arguemnet passed to console
bashEnd
-------
----win4bsd----
winpro -ws maximized
runs win4BSD max size
winpro -ws 1152x864
winpro -h
shows help for win4bsd
shift+F12
opens menu
----endwin4BSD----
whatis
apropos
searches whatis database for keyword, gives description of programs
try apropos '\(6\)'
apropos editor
shows programs that have editor in their description
scp -P 22 ./test.txt username@192.168.2.102:/usr/home/username/test.txt
copy files to remote machine -P to specify port.
scp ./test.txt username@192.168.2.102:/usr/home/username/test.txt
copy files to remote machine
scp -r ./folderToCopy username@192.168.2.102:/usr/home/username/destinationFolder/
copy directory to remote machine
scp -r '-P 1234' ./folderToCopy username@192.168.2.102:/usr/home/username/destinationFolder/
xwd -out 3rdDesktop01.xwd -root
saves screen shoot
distclean
cleans out ports files. fixes this error:
local modification time does not match remote
mkisofs -J -o out.iso -r -V volume_name directory
create iso image
/etc/netstart
restart network
-----
rc.conf
ifconfig_dc0="inet 192.168.1.2 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
hostname="whatever.what"
set static ip
dhclient ndis0
gets dynamic ip
/usr/local/etc/nagios
/usr/local/www/nagios/docs
nagios files
/usr/local/bin/nagios -v /usr/local/etc/nagios/nagios.cfg
test nagios configs
/usr/local/bin/nagios /usr/local/etc/nagios/nagios.cfg &
start nagios
shift insert
paste with keyboard
ispell
simple command line spell checker
aspell
command line spell checker
source ~/.bash_profile
reparse bash shell configuration
nspluginwrapper -v -a -i
install all plugins from their default locations (netscapePluginWrapper)
nspluginwrapper -i path/to/plugin.so
install from specific locations
nspluginwrapper -r pat/to/plugin.so
remove specific plugin
nspluginwrapper -l
list all currently installed plugins
---------
elinks
enhanced txt based browser
ESC - shows menu
endElinks
---------
ssh -D 8080 -f -C -q -N myuser@myserver.com
tunnel web traffic through ssh
fgrep word file.name
searches for word in file
ls | egrep '(wordOne|wordTwo)'
greps ls for two words
ls -1
shows files in one column
id
show userId, groupId, and groups of current user
feh --bg-scale /path/to/image.jpg
set wallpaper
echo $TERM
displays terminal type
korean
-------
export XMODIFIERS=@im=Ami
export LC_CTYPE=ko_KR.eucKR
ami &
start korean keyboard
end korean
----------
lua-5.1
start lua
rmuser dust
remove user dust
unrar x test.rar
uncompress rar
/usr/local/sbin/httpd -v
check version of apache
/usr/local/etc/rc.d/lighttpd start
start lighttpd (stop,restart,start)
killall lighttpd (if no script)
find / -type f -exec grep -H 'joemammy' {} \;
find joemammy inside files on /
grep hello ./*
find word hello in all files in current directory
vi /boot/grub/menu.lst
edit grub menu file
usbdevs -v
show usb devices
mount -t msdosfs /dev/da0s1 /mnt/camera
mounts nikon coolpix L11, must be set to mass storage under ???
---------
To install mono-merge, download it, then install with:
make install
svn must be installed to use mono-merge
mono-merge -D
merges development version from BSD# into /usr/ports
mono-merge
merges BSD# version of mono into the ports system
---------
wget -m -k -K -E http://url/of/web/site
mirror a website
wget --spider --force-html -i bookmarks.html
use wget to check validity of bookmarks
ls -l | grep '^d'
list directories in current folder ('^d' looks for lines starting with a d)
ls -l | grep '^d' | awk '{ print $NF }'
shows on the folder names of the directories
chmod u+x ./scriptFile
add executable permission to scriptFile for current user
find ./ -type f | xargs perl -pi -e 's!/usr/bin/ruby!/usr/local/bin/ruby!g'
search all files in a folder and replace: /usr/bin/ruby with: /usr/local/bin/ruby
ls | awk '{print "<a href=\""$1"\">"$1"</a>"}' > index.html
make html links to every file in the current directory inside index.html
ls | awk '{print "<a href=\""$1"\">"$1"</a>"}' >> index.html
same as above except appends the links to index.html
ls | awk '{print "<img src=\""$1"\">"$1"<br>"}' > index.html
create img tags for every file in directory and write to index.html
grep ruby ./*
look for any files in current folder that contain the word: ruby
tar -zcvf nameOfTarFileToCreate.tar.gz ./DirectoryWantedCompressed
tar a file to a .tar.gz
tar -zxvf ./nameOfFileToExtract
untar a file
mysql_install_db
run this after first install to finish setup
GRANT ALL ON dbName.* TO 'testuser'@'localhost' IDENTIFIED BY 'testpassword';
give user rights to a mysql database
insert into grid (x, y) values ('-98', '-98');
add x and y to table grid
delete from settlements where id='61';
deletes the row/record in table settlements that has id matches 61
update users set x='-98', y='-98' where id='2292';
update record x,y in table users with -98,-98 that matches id 2292
mysql -u user-name -p db-name < db-template.sql
transfer mysql database
-----------------------
mysqldump --quick db_name | gzip > db_name.gz
dump database to a gzip file to transfer to new machine
mysqladmin create db_name
create databse on new machine
gunzip < db_name.gz | mysql db_name
unzip and databse and throw it in mysql
--------------------------
xconsole
if installed can show what syslogd is writing to ttyv0, inside of X
grep "^ :" 00_data.txt | sed '$!N;s/\n/ /' | awk '{print $1 $2 $5}' > 00data.txt
greps for 4 spaces the : at the beginning of each line. sed combines every two lines. awk prints the 1st 2nd and 5th field of each line. > writes it to 00data.txt
Crontab
-------
crontab -e
edit the crontab for the user you are logged in as
Mutt
-----
$
purges deleted messages
end mutt
--------
tmux
----
attach -d -t0
attatch to session 0
end tmux
--------
tcpdump -s0 -X -i bge0 port 80
watch what is happening on port 80
javascript:alert(unescape(document.cookie))
type this in as a browser url, to see the cookies on a webpage
pstree
list processes as a tree (must be installed)
tree -a
show directories in a tree view. (must be installed)
mogrify -resize 75x75 ./*.jpg
resize all jpg in current directory to 75x75 (requires imagemagick to be installed)
xwininfo -tree
show info abou twindows
(xwininfo and xininfo show info about windows)
grep
----
grep -r "jowdaddy" /home
recursively search for jowdaddy inside files located in your /home
grep -v notmeplease
show all lines that do not match notmeplease
find
----
find /home /tmp -name yasister.txtme
search /home and /tmp directories for yasister.txtme
find ./learn -ls
displays inode number (inode serial), size in 512-byte blocks, file permissions, number of hard links, owner, group, size in bytes, last modification time, and pathname.
**very similar output as (ls -igls)
find `script-that-chooses-dirs` -name choosenFile
uses a script to choose which files to search for chosen file
find ./learn -type f -size 0 -ls
search learn folder for a regular file that has file size of 0 and display in long format
find /usr/home /var/html /usr/local/www -name "*.htm*" -print
find all files with names containing .htm (-print is the default and prints to standard out) so the previous command is equivelant to:
find /usr/home /var/html /usr/local/www -name "*.htm*"
**all regex need to be quoted or they will be passed to the shell rather than find
find ./ -iname RECIPE.txt
case insensitive search for recipe.txt in current folder
find $HOME -mtime -1
find files in the home directory modified in the last 24 hours
find $HOME -mtime +365
find files that have not been modified in the last year
find /home/username -mtime -7 -name "*.htm*"
find htm/html files that have been modified in the last week (7 24hour)
find /home/user/www -mtime 7 -name "*.php*"
search for files that were modified exactly a week ago
find /var/log -mtime +7 -name "*.log"
find files that have not been modified for at least a week
find /$HOME/pics -newer $HOME/scripts/resize-pics.rb
find files in pics folder that have been modified more recently than resize.pics.rb
find /home -name "*.txt" -size 100k
find /home -name "*.txt" -size +100k
find /home -name "*.txt" -size -100k
display files that are 100k in size / more than 100k in size / less than 100k in size
find . -name '*.jpg' -exec ls {} \;
find all jpgs in current directory and use ls to display them
find $HOME/. -name '*.jpg' -ok rm {} \;
find all jpgs in current directory and ask for confirmation before deleting each
touch thisNewFile
creates a new empty file named thisNewFile
ls -s /someDirectory/originalFile /anotherDirectory/linkedToOriginalFile
creates a file that is linked to another. Editing the linked file changes the original
rm -f aFileThatNeedsDeleting
deletes a file without asking
rm -rf byeByeDirectory
deletes a directory and everything in it without asking
file somefile
attempts to guess type of file by its content
file *
guess filetypes of all files in a directory
wc filename
counts lines, words, and characters in a file
wc -l filename
counts lines in a file
ls -al > ./saveLsOutput.txt
overwrites text file with ls' output or creates an new file
ls -al >> ./saveThis.txt
appends output to file or creates new one if it does not exist
<
send input from a file back into a command
mplayer -vo xv dvd://1
play dvd
mplayer -nocache -playlist "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=15364&file=filename.pls"
play shoutcast stream
baobab
gui that shows disk usage
# When getting a mount error like this:
mount: /dev/ada2p7: R/W mount of /mnt/some-disk denied.
Filesystem is not clean - run fsck. Forced mount will
invalidate journal contents: Operation not permitted
#
# Run:
doas fsck -y /dev/ada2p7
#
# Then try to mount again
doas mount /dev/ada2p7 /mnt/some-disk
mail
----
d 1-5
deletes messages 1 through 5
t <message list> type messages
n goto and type next message
e <message list> edit messages
f <message list> give head lines of messages
d <message list> delete messages
s <message list> file append messages to file
u <message list> undelete messages
R <message list> reply to message senders
r <message list> reply to message senders and all recipients
pre <message list> make messages go back to /var/mail
m <user list> mail to specific users
q quit, saving unresolved messages in mbox
x quit, do not remove system mailbox
h print out active message headers
! shell escape
? print this help message
# display message number #
- print previous
+ next (no delete)
! cmd execute cmd
<CR> next (no delete)
a position at and read newly arrived mail
d [#] delete message # (default current message)
dp delete current message and print the next
dq delete current message and exit
h a display all headers
h d display headers of letters scheduled for deletion
h [#] display headers around # (default current message)
m user mail (and delete) current message to user
n next (no delete)
p print (override any warnings of binary content)
P override default 'brief' mode and display ALL header lines
q, ^D quit
r [args] reply to (and delete) current letter via mail [args]
s [files] save (and delete) current message (default mbox)
u [#] undelete message # (default current message)
w [files] save (and delete) current message without header
x exit without changing mail
y [files] save (and delete) current message (default mbox)
# Error Mounting a drive:
mount: /dev/ada2p7: R/W mount of /mnt/old-home denied. Filesystem is not clean - run fsck.
Forced mount will invalidate journal contents: Operation not permitted
-
# Need to run fsck:
doas fsck -y /dev/ada2p7
default