Before You Post, Please Note...

-> Please Note: By Posting, you agree to submit the contents of your post to the Public Domain <- SEE: howto post to this blog

Friday, January 12, 2007

bash howto for dos lovers

the following is aimed at dos users that are not already extremely comfortable with the command line interface (cli) in linux, and also may be useful to linux users that aren't already extremely comfortable with the dos cli, and should be useful without or in xwin.


attrib

examples:
attrib *.*
# shows attributes of all files a h r s (archive hidden readonly system)
attrib *.txt +a
# set all txt files to have archive attribute (*.* applies only to current folder)
attrib *.* -a -h -r -s
# remove all attributes from all files
# (if you cant change attributes in dos the file is locked, or, remove -a -h -r -s at once)

in linux:
chmod
(and/or)
chattr
(and/or)
chown
examples:
chmod 777 hello.sh
# makes it so everyone can read, write, or run a file (as an executable)
# for executable files (binary and scripts) chmod 755 hello.sh is better
# chattr changes some attributes of files (somehow...)
# chown changes the owner of the file


cls

examples:
cls
# clears the screen

in linux:
#where is it? cls? clear? clr? home? cl?
#here it is:
reset
# does the whole scrolly bit over, like closing rxvt and reopening it (that part applies more to xwin of course)


copy

examples:
copy hello.txt hello.bak
# makes a backup of hello.txt
copy a:\*.txt c:\hello
# copies all files ending in .txt in a:\ to a folder called hello on the c: drive, but does not work unless folder exists
# usually, and used from the console, copy will ask before overwriting an existing file. not usually from a script

in linux:
cp hello.txt hello.bak
# same as dos example
cp /mnt/floppy/*.txt /mnt/home/hello
# assumes floppy and c: drive are at the above mount points. will create folder called hello if it doesn't exist
# cp does not ask before overwriting. using cp -i instead of just cp will force interaction (not overwrite without asking)


cd (or) chdir

examples:
a:
cd \
# changes to a drive and folder \
cd ..
# changes to parent folder
cd \hello\there
# changes to hello\there folder from \
cd there
# changes to there from current folder
cd
# displays current folder

in linux:
# virtually the same. in dos, cd/ and cd.. are okay, in linux the space is required: cd / and cd ..
# you have to use cd (instead of chdir)
# cd (nothing else) does not show the current folder in linux. pwd (print working directory) is used instead.
# to change to the "a:" drive in linux (from the gui)
# run mut from xwin (or click the drives icon) and click [scan] on fd0
# click [mount]
# from the console:
cd /mnt/floppy
# when done: click [unmount]
# click [noscan]
# you could also learn how to use mount from the console (sorry, not included in this howto)
# mut is so great, someone should make a console version that uses keys like a b c d e f g h (buttons, not driveletters!)
# (maybe barry or mu or i will make a console version someday? don't know what it entails)


del (or) delete (or) erase

examples
del *.*
del .
# (either one) deletes all files in a folder
del *.txt
# deletes all files ending in .txt
del hello.txt
# deletes hello.txt

in linux:
# be careful with * wildcards!
# if you are going to use a wildcard, use "ls [wildcards]" instead of "rm [wildcards]" to see what may be deleted...
rm *
# deletes files; if someone randomly tells you to type rm -f * or something like that, kick him. hard...
rm *txt
# deletes files ending in txt
# -r is recursive (recursion in dos and linux are not exactly the same, that's why you don't see more notes on it here)


dir

dir *.txt
# list all txt files
dir *.txt /b /a > list.txt
# list all txt files even if they are hidden. /b says just show filenames... send output to list.txt
dir /w
# show files in a multicolumn layout
dir c:\*at* /a /s
# show all files in all folders in the c drive, if the filename contains "at"
dir /?
# show more info on dir. works on many dos commands

in linux:
ls *.txt
# same as in dos, but if there is a folder called something.txt it will show that folder too, etc.
ls *.txt -1 -a > list.txt
# include "hidden" files that start with . (yeah they are hidden) in one column... send output to list.txt
ls
# this is more like dir /w
ls -l
# that's an l like in "linux" not to be confused with -1 (one) from the other example. this outputs more like dir
ls /*at* -a
# show all files containing "at" in the name, but only in the / folder, and any folders recursed that also include "at"
ls --help
# show more info on ls. works on many linux commands
# here's a really good one, thanks to jcoder24 for it:
find / -depth -name *at*
# this is much closer to dir /s /b in dos, and in xwin try it with: | leafpad &


exit

examples:
exit
# closes the console in windows

in linux:
# it's the same, but will close the apps opened from the console too.
# the way around this is to append any command with & for instance:
leafpad hello.txt &
# now hit enter a couple times (or wait a minute)
exit
# right. also, if you click [X] on the window, the & is moot... it closes apps even if they were run with &


echo

examples:
echo
# display if "echo" is on or off
echo.
# echo a blank line (useful in scripts to look nice)
echo cd \ > hello.bat
echo dir *.txt >> hello.bat
# this creates a script called hello.bat that changes to the \ folder and shows the .txt files there.
# > writes to a file (overwrite / create new)
# >> apppends to a file (append / create if not existing)
# to run the script, enter:
hello
# you can type hello.bat but the suffix is required in the name

in linux:
echo
# blank line, same as echo. in dos
echo cd / > hello.sh
echo ls *.txt >> hello.sh
chmod 755 hello.sh
# creates the same script as above and makes the script executable
# to run the script, enter:
./hello.sh
# you must type .sh at the end if it's part if the name, but you don't have to name it that way


fc

examples:
fc hello.txt hello.bak
# show the differences between the two files, if any
fc /b hello.exe hello2.exe
# do a binary comparison of files (shows differences in hex, if any)

in linux:
diff hello.txt hello.bak
# basically the same idea. for binary files, you can try just using diff
# also, you can try this:
md5sum hello
md5sum hello2

usually when two files are different, the single-line md5sum is different. file integrity checking is often done this way


move

examples:
move *.txt a:\hey
# move all .txt files to a:\hey
move hellofolder hello2folder
# rename a folder

in linux:
mv *.txt /mnt/floppy/hey
# same as above, assumes mountpoint at /mnt/floppy
mv hellofolder hello2folder
# rename a folder


md (or) mkdir

examples:
md hello
# create folder named "hello"
mkdir hello
# same thing
md /mnt/home/hello
# create "hello" folder in /mnt/home
mkdir /mnt/home/hello
# same thing

in linux:
# you have to use mkdir (instead of md)


ren (or) rename

examples:
ren hello.txt hello.bak
#rename the file to...

in linux:
mv hello.txt hello.bak


rd (or) rmdir

examples:
rd thisisafolder

in linux:
rm -r thisisafolder
# dos won't usually let you remove a folder that has files in it
# linux usually will


rem

examples:
rem hey look, this does nothing!

in linux:
# this usually does nothing!
# however, the following is used to identify a bash script:
#!/bin/sh
# the following is used to identify a puppybasic script:
#!/usr/bin/wxbasicscript
# you get the idea. technically, it STILL does nothing... but it does, however, change how a script is interpreted
# (or how a file is identified)
# all bash scripts should really start that way you know:
#!/bin/sh
# but my creation of a script using echo without that header still worked


start

examples:
start notepad
start http://pupweb.org
#this is really a windows thing... but a command preceded by "start" sometimes works when it ohterwise would not
start cmd /c dir | more
# opens a new console, runs dir and pipes to more

in linux:
# exec is somewhat, but not exactly, like start. xwin does not need to be running to use it.
# sometimes preceding a command with exec helps in .rc files when you want to run a command
# to open a website, use defaultbrowser:
defaultbrowser http://pupweb.org
# to open a new console:
rxvt &
# to run a command in a new console:
rxvt -e ls | more
# opens a new console, runs dir and pipes to more


time

examples:
time
# shows/sets current time
time 00:00:00
# sets time to midnight
# to do the same with the date:
date

in linux:
date
# shows the time (it also shows the date)


type

examples:
type hello.txt
# displays a text file
type hello.txt | more
# displays a text file with more
more hello.txt
# same as the previous example

in linux:
more hello.txt
# same as dos
less hello.txt
# "less is more" Razz less lets you scroll... (caveat, i forget how to make it stop)
more hello.txt | leafpad
# that one is fun, try with ls or find (does not work with mp)
# this seems to work:
more hello.txt | less
# the idea being more useful with things like ls and find since leafpad isnt available when xwin isn't
# if you don't love any of those, try using cat for type:
cat hello.txt


questions? other tips? ideas? (corrections?) reply!

notes:
want to wiki? lobster made a wiki page and wants to know how it can be better formatted: http://puppylinux.org/wikka/DosCli

gn2 suggests this alternative bash<->dos page: http://www.yolinux.com/TUTORIALS/unix_for_dos_users.html

also, there is a really amazing page on this subject at the linux doc project: http://tldp.org


KTWI: most of these were tried in puppy 2.11 and most should work in 1.07, nohup is available in puppy 2.12 and later.

thanks to: lobster, dougal, gn2, "chandlerman", amish

29 comments:

Anonymous said...

Hey,

I am regular visitor of this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]puppydocblognode1.blogspot.com is filled with quality info. Do you pay attention towards your health?. In plain english I must warn you that, you are not serious about your health. Recent Scientific Research displays that about 70% of all U.S. grownups are either obese or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Therefore if you're one of these individuals, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? Quick weight loss can be achived with little effort. If you improve some of your daily diet habbits then, its like piece of cake to quickly lose weight.

About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effortless weight loss.

Anonymous said...

Sorry for my bad english. Thank you so much for your good post. Your post helped me in my college assignment, If you can provide me more details please email me.

Anonymous said...

Brilliant phrase and it is duly

Anonymous said...

I to you will remember it! I will pay off with you!

Anonymous said...

Thanks for this useful article.

Anonymous said...

Hi comrade How are You ? I like your advise and i be to stagger it for my friend but i cant realize your collective bookmark widget in this blog. Content cure me admin Recognition You Steven
[IMG]http://www.sedonarapidweightloss.com/weightloss-diet/34/b/happy.gif[/IMG]

Anonymous said...

buy tramadol online buy tramadol england - order tramadol online tennessee

Anonymous said...

buy tramadol online many tramadol 50mg get high - what does tramadol withdrawal feel like

Anonymous said...

tramadol overnight shipping zodol-tramadol 50 mg - tramadol 50mg and hydrocodone

Anonymous said...

buy tramadol online can you buy tramadol legally online - tramadol 50mg used dogs

Anonymous said...

buy tramadol online tramadol make you high - tramadol 100mg side effects

Anonymous said...

tramadol 50 mg buy tramadol online no prescription next day delivery - ultram side effects weight loss

Anonymous said...

buy tramadol online tramadol and ultram - tramadol 50 mg and beer

Anonymous said...

buy tramadol online tramadol for dogs constipation - tramadol online shipped to florida

Anonymous said...

buy tramadol online tramadol for dogs 50mg dosage - buy tramadol online overnight cod

Anonymous said...

cialis online get cialis online pharmacy - cialis online with mastercard

Anonymous said...

xanax online how long does 1mg xanax work for - xanax treats anxiety

Anonymous said...

xanax online xanax brand versus generic - xanax bars many mg

Anonymous said...

cialis online buy cialis online with prescription - generic cialis us suppliers

Anonymous said...

xanax online buy alprazolam online cheap - much 1mg xanax cost

Anonymous said...

http://landvoicelearning.com/#21906 tramadol 93 58 side effects - tramadol online credit card

Anonymous said...

buy tramadol tramadol 100 mg lp - tramadol online saturday delivery

Anonymous said...

http://landvoicelearning.com/#21906 buy tramadol overnight cod - ultram tramadol withdrawal

Anonymous said...

buy tramadol zydol tramadol dosage - tramadol online no prescription needed

Anonymous said...

tramadol 50 mg tramadol 50mg recreational - where can i buy tramadol for my dog

Anonymous said...

buy tramadol saturday delivery tramadol 50mg for pets - lethal dose tramadol

Anonymous said...

http://reidmoody.com/#54126 ativan addiction potential - ativan overdose treatment

Anonymous said...

http://ranchodelastortugas.com/#50698 xanax muscle relaxer - saliva drug test detection times xanax

Anonymous said...

http://ranchodelastortugas.com/#58720 xanax side effects uti - xanax 2mg images