You are not logged in.
well, i apparently got too much time on my hands. here are some of the most basic, simple, 'omg you didnt know that!?!?' commands (with explanations!) for all you newbies and GUI-addicts 
lots of times we're taking these for granted, because we use them all the time. but they're apps and commands in their own right. they are the core of the KISS/'do one thing and do it right' philosophy. you'll find these anywhere and they are awesome.
if you're new to this, i highly recommend and encourage you to try these out for yourself. just make yourself a new directory with some more directories and a bunch of files for testing (the commands to do this are somewhere below!)
<stuff between these triangles> means User Input.
# means a comment (so no longer part of the command) (the amount of #'s doesn't matter)
man <command> # get the manual of a command. use this on everything below for even more information!SOME FILES AND DIRECTORIES STUFF
mkdir <dir> # make a directory
touch <file> # make an (empty) file
ls # list the contents of a directory (from now on: dir)
ls -l # shows you the long version of 'ls'
ls -a # shows you all the files, including hidden files
pwd # tells you which directory you are in
cd <dir> # navigate to <dir>
cd <dir>/<dir>/<dir> # you can guess this one, right?
cd .. # navigate one directory 'up' in the directory tree
mv <file> <dir> # move <file> to <dir>
mv -i <file> <dir> # move <file> to <dir> with confirmation on overwrite (-i = --interactive)
mv <file> <new filename> # change the filename of <file> to <new filename>
cp <file> <new file> # copy <file> to <new file>
cp -i <file> <new file> # copy <file> to <new file> with confirmation on overwrite
cp <file> <dir> # copy <file> to <dir> (keeping its name)
cp -r <dir> <other dir> # you cannot copy directories without using the -r (recursive) option
rm <file> # remove <file>
rm -i <file> # remove <file> with confirmation
rm -r <dir> # you cannot remove a directory without using the -r optionSOME FILE DISPLAY AND INFO AND REDIRECTION
clear # clears the screen
echo "a big pile of poop" # prints "a big pile of poop" to your screen. try it!
cat <file> # concatenate (errr... display?) the contents of a file. gives you sensible output on text-files etc, and messes up your terminal on compiled stuff.
file <file> # tells you what kind of file it isthis symbol: | is a pipe. you use it to pipe the output of one command to the input of another. for example:
cat sometext.txt | more # pipes the output of the cat-command to the more-command (more on that later! :D)this symbol: > redirects the output of a command to a file. for example:
ls > thisisinmydirectory.txt # you now have a file which has the contents of your directory! jeeej!this symbol: >> is the same as > but appends it to the end of the file, so it doesn't overwrite what is already there. example:
[02:04:50]$ echo "meh" > bla.txt
[02:04:56]$ cat bla.txt
meh
[02:04:58]$ echo "huu" >> bla.txt
[02:05:09]$ cat bla.txt
meh
huuSOME MORE STUFF
more alongtextfile.txtif your text-file is long, 'more' stops it from scrolling off the screen. press [SPACE] to see the next screen. press 'q' to quit.
less alongtextfile.txtsame as more. what? it's called less, but does more than more. confused? read here for more (hahaha): http://crunchbanglinux.org/forums/topic … x-is-more/
both more and less are called 'pagers'. if you tried the 'man' command, you've already seen one of them. to see what kind of pager you use by default, just check out the $PAGER global variable, like so:
[02:05:49]$ echo $PAGER
less -Xi use less -X. now you can figure out what that means 
ADVANCED STUFF (or not so advanced but okay)
the symbol ~ means your 'home'. in my case, /home/rhowaldt. this is the same as $HOME:
[02:22:58]$ echo ~
/home/rhowaldt
[02:22:59]$ echo $HOME
/home/rhowaldtthe symbol: . means the current directory. so this:
cp /media/storage/mp3/* .means: copy everything inside of the /media/storage/mp3 directory to my current directory.
mv *.mp3 /media/storage/mp3moves all the files ending in .mp3 inside the current directory to the directory /media/storage/mp3. the * means 'everything'. it is a Regular Expression. i'm not going to explain any more than *, but here's a cheatsheet: http://krijnhoetmer.nl/stuff/regex/cheat-sheet/
su # switch user. without arguments, switches to the root-user
sudo <command> # makes you root temporarily and executes the command. example:
sudo apt-get install gimpSEARCH
which <command> # tells you which command will be executed when you type 'command'. example:
[02:24:20]$ which python
/usr/bin/python
apropos <something> # searches the manualpages for <something>
find . -name "poop" # starts searching from the current directory (.) and looks for filenames with 'poop'
find / -name "mehh" # starts searching from the root (/) directory and looks for filenames with 'mehh'cat mytextfile.txt | grep "chewbacca"returns any lines that have 'chewbacca' in them. grep is too huge to explain here. please just Google about this if you want more info. the same goes for sed and awk, which i'm not even going to start about.
exit # take a wild guess!so, that is about it as far as the absolute basics go. if you are getting enthusiastic, here are some more links for further reading:
http://crunchbanglinux.org/forums/topic … and-lines/ - whole bunch of other commandlines
http://crunchbanglinux.org/forums/topic … resources/ - the terminal by default uses a language called 'bash'. here is everything you basically need to know about that gathered in one place.
have some fun! 
Offline
Omg! 
Offline
Very nice.
Do you think that some simple ssh/scp commands would fit?
ssh is useful if you need to kill something that is locking up X.
scp lets you copy files over a network a lot easier than setting up nfs or samba.
Offline
well, i apparently got too much time on my hands.
Exactly what I thought when I saw the title. 
Edit: -- never mind --
Last edited by Tunafish (2012-06-09 08:34:07)
sed 's/stress/relaxation/g'
Privacy & Security on #!
Offline
You are trying to create a replacement for the Arch wiki here, right?
Offline
You are trying to create a replacement for the Arch wiki here, right?
We can always fork it 
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github || Deviantart
Offline
thanks for all the nice/funny/weird comments you guys 
Offline
Thank you very much.
Having learned to use the "terminal" in Windows, I was always using cd.. to move upward in directory trees... little did I know that I needed a space 
I think I'll save a local copy of this post just in case.
I've made a huge mistake
Offline
cd #will take you to the Home directory of the user you are at that time
cat > filename # will input whatever you type into a filr until you hit ctrl-dLast edited by griffen76 (2012-06-11 21:17:49)
Offline
cd - # will return you to the last directory you were before the current one
:(){ :|:&};: # allows you to play tetris in your ttyLast edited by Awebb (2012-06-11 21:28:16)
I'm so meta, even this acronym
Offline
I cannot believe you started a thread on command line basics without including the most basic of commands!!
wYour life in one, single-letter command 
Last edited by gutterslob (2012-06-12 01:17:07)
Point & Squirt
Offline
@Awebb: you're deploying the fork-bomb again i see 
@gutterslob: well, i have a single-user system so i never really use 'w', which is why i forgot!
Offline
Nice overview for the basics, rhowaldt.
But I have one question. I guess for every cat used in this combination a kittie is tortured
cat mytextfile.txt | grep "chewbacca"
Don't you like kitties? 
Why don't you use
grep "chewbacca" mytextfile.txtOffline
^ yes, you are right, of course. however, i think that is 'advanced' stuff. maybe i should've used another example, but i took the one i thought of the first, even though it is a waste of resources 
Offline
Very sexy 
For the fetishists: http://linuxers.org/article/10-bash-sho … hould-know
Offline
I've been telling these people up and down to avoid pipes, but they obviously don't care, like the honeybadger. I'm not sure, this is quite a basic thing.
Avoid pipes. Use the tool's own filter options and input calls.
WRONG
cat file.txt | grep "burp"
find /home | grep mynudes*jpgRIGHT
grep "burp" file.txt
find /home -iname mynudes*jpgBUT
find /home | egrep (a$$l0ngr3gu14r3xpr3550n|really\ long\ regular\ expression)
locate beer | grep "locate has no real filter so we use grep.txt"Remember, piping usually works well, as in 'it does the job', but you will find many things not working as they should, as in piping or redirecting text via sudo. There are also many tools not accepting standard output from the pipe. Avoiding pipes is considered to be good style, because of such pitfalls. Another reason is that every time you use a pipe, a new process is forked, using CPU and RAM. This might sound irrelevant, if you only invoke single line commands once in a while, but the faster you learn good style, the less trouble will you have later unlearning those old habits.
Writing to a file not belonging to the user with sudo:
echo "text" | sudo tee /etc/text.confThis will overwrite the file text.conf with the single word "text"
echo "text" | sudo tee -a /etc/text.confThis will append "text" in a new line of the file text.conf
Producing a command line from many lines of standard output:
locate beer | xargs rmLocate produces output like this:
/usr/share/zim/manual/Help/Auto_Formatting.txt
/usr/share/zim/manual/Help/Check_Boxes.txt
/usr/share/zim/manual/Help/Config_Files.txt
/usr/share/zim/manual/Help/Custom_Tools.txt
/usr/share/zim/manual/Help/Export.txt
/usr/share/zim/manual/Help/Importing_external_files.txt
/usr/share/zim/manual/Help/Key_Bindings.txt
/usr/share/zim/manual/Help/Links.txt
/usr/share/zim/manual/Help/Menu_Items.txt
/usr/share/zim/manual/Help/Notebooks.txt
/usr/share/zim/manual/Help/Pages.txt
/usr/share/zim/manual/Help/Preferences.txt
/usr/share/zim/manual/Help/Properties.txt
/usr/share/zim/manual/Help/Searching.txt
/usr/share/zim/manual/Help/Tags.txt
/usr/share/zim/manual/Help/Templates.txt
/usr/share/zim/manual/Help/Wiki_Syntax.txt
/usr/share/zim/manual/Help/Export/HTML.txt
/usr/share/zim/manual/Help/Export/LaTeX.txt
/usr/share/zim/manual/Plugins/Arithmetic.txt
/usr/share/zim/manual/Plugins/Automount.txt
/usr/share/zim/manual/Plugins/Calendar.txt
/usr/share/zim/manual/Plugins/Diagram_Editor.txt
/usr/share/zim/manual/Plugins/Ditaa_Editor.txt
/usr/share/zim/manual/Plugins/Equation_Editor.txt
/usr/share/zim/manual/Plugins/GNU_R_Plot_Editor.txt
/usr/share/zim/manual/Plugins/Gnuplot_Editor.txt
/usr/share/zim/manual/Plugins/Inline_Calculator.txt
/usr/share/zim/manual/Plugins/Insert_Screenshot.txt
/usr/share/zim/manual/Plugins/Insert_Symbol.txt
/usr/share/zim/manual/Plugins/Link_Map.txt
/usr/share/zim/manual/Plugins/Quick_Note.txt
/usr/share/zim/manual/Plugins/Spell_Checker.txt
/usr/share/zim/manual/Plugins/Table_Of_Contents.txt
/usr/share/zim/manual/Plugins/Tags.txt
/usr/share/zim/manual/Plugins/Task_List.txt
/usr/share/zim/manual/Plugins/Tray_Icon.txt
/usr/share/zim/manual/Plugins/Version_Control.txt
/usr/share/zim/manual/Usage/Daily_Journal.txt
/usr/share/zim/manual/Usage/Getting_Started.txt
/usr/share/zim/manual/Usage/Getting_Things_Done.txt
/usr/share/zim/templates/_quicknote.txt
/usr/share/zim/templates/wiki/Calendar.txt
/usr/share/zim/templates/wiki/Default.txt
/var/lib/pacman/local/xls2txt-0.12-1
/var/lib/pacman/local/xls2txt-0.12-1/desc
/var/lib/pacman/local/xls2txt-0.12-1/filesPiping it through xargs will transform the output to a single line:
/usr/share/vim/vim73/doc/windows.txt /usr/share/vim/vim73/doc/workshop.txt /usr/share/vim/vim73/ftplugin/README.txt /usr/share/vim/vim73/indent/README.txt /usr/share/vim/vim73/keymap/README.txt /usr/share/vim/vim73/lang/README.txt /usr/share/vim/vim73/macros/README.txt /usr/share/vim/vim73/macros/matchit.txt /usr/share/vim/vim73/macros/maze/README.txt /usr/share/vim/vim73/macros/urm/README.txt /usr/share/vim/vim73/plugin/README.txt /usr/share/vim/vim73/syntax/README.txt /usr/share/vim/vim73/tools/README.txt /usr/share/vim/vim73/tools/ccfilter_README.txt /usr/share/vim/vim73/tools/efm_filter.txt /usr/share/vim/vim73/tools/mve.txt /usr/share/vim/vim73/tools/vimspell.txt /usr/share/vim/vim73/tutor/README.el.cp737.txt /usr/share/vim/vim73/tutor/README.el.txt /usr/share/vim/vim73/tutor/README.txt /usr/share/vim/vimfiles/doc/LargeFile.txt /usr/share/wmclock/lang.polish/month.txt /usr/share/wmclock/lang.polish/weekday.txt /usr/share/zim/manual/About.txt /usr/share/zim/manual/Bugs.txt /usr/share/zim/manual/FAQ.txt /usr/share/zim/manual/Help.txt /usr/share/zim/manual/Plugins.txt /usr/share/zim/manual/Start.txt /usr/share/zim/manual/Usage.txt /usr/share/zim/manual/Help/Auto_Formatting.txt /usr/share/zim/manual/Help/Check_Boxes.txt /usr/share/zim/manual/Help/Config_Files.txt /usr/share/zim/manual/Help/Custom_Tools.txt /usr/share/zim/manual/Help/Export.txt /usr/share/zim/manual/Help/Importing_external_files.txt /usr/share/zim/manual/Help/Key_Bindings.txt /usr/share/zim/manual/Help/Links.txt /usr/share/zim/manual/Help/Menu_Items.txt /usr/share/zim/manual/Help/Notebooks.txt /usr/share/zim/manual/Help/Pages.txt /usr/share/zim/manual/Help/Preferences.txt /usr/share/zim/manual/Help/Properties.txt /usr/share/zim/manual/Help/Searching.txt /usr/share/zim/manual/Help/Tags.txt /usr/share/zim/manual/Help/Templates.txt /usr/share/zim/manual/Help/Wiki_Syntax.txt /usr/share/zim/manual/Help/Export/HTML.txt /usr/share/zim/manual/Help/Export/LaTeX.txt /usr/share/zim/manual/Plugins/Arithmetic.txt /usr/share/zim/manual/Plugins/Automount.txt /usr/share/zim/manual/Plugins/Calendar.txt /usr/share/zim/manual/Plugins/Diagram_Editor.txt /usr/share/zim/manual/Plugins/Ditaa_Editor.txt /usr/share/zim/manual/Plugins/Equation_Editor.txt /usr/share/zim/manual/Plugins/GNU_R_Plot_Editor.txt /usr/share/zim/manual/Plugins/Gnuplot_Editor.txt /usr/share/zim/manual/Plugins/Inline_Calculator.txt /usr/share/zim/manual/Plugins/Insert_Screenshot.txt /usr/share/zim/manual/Plugins/Insert_Symbol.txt /usr/share/zim/manual/Plugins/Link_Map.txt /usr/share/zim/manual/Plugins/Quick_Note.txt /usr/share/zim/manual/Plugins/Spell_Checker.txt /usr/share/zim/manual/Plugins/Table_Of_Contents.txt /usr/share/zim/manual/Plugins/Tags.txt /usr/share/zim/manual/Plugins/Task_List.txt /usr/share/zim/manual/Plugins/Tray_Icon.txt /usr/share/zim/manual/Plugins/Version_Control.txt /usr/share/zim/manual/Usage/Daily_Journal.txt /usr/share/zim/manual/Usage/Getting_Started.txt /usr/share/zim/manual/Usage/Getting_Things_Done.txt /usr/share/zim/templates/_quicknote.txt /usr/share/zim/templates/wiki/Calendar.txt /usr/share/zim/templates/wiki/Default.txt /var/lib/pacman/local/xls2txt-0.12-1 /var/lib/pacman/local/xls2txt-0.12-1/desc /var/lib/pacman/local/xls2txt-0.12-1/filesYou can now feed it to whatever is taking single lines of arguments. Like a list of urls for firefox.
cat linklist.txt | xargs firefoxWe need cat here, as firefox does not accept text files for link input, it would open the file instead.
Last edited by Awebb (2012-06-12 11:12:30)
I'm so meta, even this acronym
Offline
^ thanks for the elaborate explanation Awebb. that's one i couldn't have written so clearly myself.
Offline
Producing a command line from many lines of standard output:
locate beer | xargs rm
What about filenames with spaces in? You might be deleting what you didn't expect. With find you can use the -print0 option, and the -0 option with xargs to avoid this problem. Locate's -0 option might work here. ie
locate -0 beer | xargs -0 rmBut I haven't tried it.
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
i like ctrl - r (search cmd line history) hit that, start typing 'sm' and (if it's been typed already) boom - 'sudo geany /etc/samba/smb.conf' appears.
useful if, like me, you need to run the same cmds over and over..
ohh and- Shift- Pg-up -should- scroll up,(and pg- dwn - well, down) sometimes real handy in a 'real' console. ie S*l*n* G*m*z!! what was the output from the ls -a i did at the beginning - or oops i forgot to pipe that huge dir listing to more (or less).... 
I 'member even on DOS one could use a 'switch' to list 'dir' one page at a time...
Last edited by wuxmedia (2012-06-13 22:31:58)
Offline
With find you can use the -print0 option, and the -0 option with xargs to avoid this problem.
Oh, that's useful.
Locate doesn't seem to be the scripter's friend anyway. However, this is nothing another pipe and sed can't fix :-D
I'm so meta, even this acronym
Offline
just dropping in to link to another post that might be useful to newcomers for learning a bit about this stuff: http://crunchbanglinux.org/forums/post/244133/#p244133
Offline
<> these are not triangles rhowaldt they are less than and greater than symbols

But thank you for the guide 
Last edited by mariannemarlow (2012-07-20 17:09:31)
Between two evils, I always pick the one I never tried before ~ Mae West
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.