• Same story, different day...........year ie more of the same fiat floods the world
  • There are no markets
  • "Spreading the ideas of freedom loving people on matters regarding high finance, politics, constructionist Constitution, and mental masturbation of all types"

Linux/Win Command Line Basics

Joined
Nov 15, 2016
Messages
214
Likes
95
#1
Ran across this the other day and brought back memories of when I was in college. They didn't teach a lot of this stuff.

I'm skipping ahead a little cause if you really want to learn you should go to that first link and do the first few exercises. It's all free.

https://learnpythonthehardway.org/book/
Exercise 3: If You Get Lost
As you go through these instructions you may get lost. You may not know where you are or where a file is and have no idea how to continue. To solve this problem I am going to teach you the commands to type to stop being lost.

Whenever you get lost, it is most likely because you were typing commands and have no idea where you've ended up. What you should do is type pwd to print your current directory. This tells you where you are.

The next thing is you need to have a way of getting back to where you are safe, your home. To do this type cd ~ and you are back in your home.
Do More
A very important part of learning to use the command line interface (CLI) on a computer with a graphical user interface (GUI) is figuring out how they work together. When I started using computers there was no "GUI" and you did everything with the DOS prompt (the CLI). Later, when computers became powerful enough that everyone could have graphics, it was simple for me to match CLI directories with GUI windows and folders.

Most people today, however, have no comprehension of the CLI, paths, and directories. In fact, it's very difficult to teach it to them and the only way to learn about the connection is for you to constantly work with the CLI until one day it clicks that things you do in the GUI will show up in the CLI.

https://www.ibm.com/developerworks/aix/library/au-directorytree/
Where am I?
Okay. Your cd command didn't report any failures, so you assume that it worked. But it would be nice to know for sure which directory you're now in.

Of course, you could run the pwd command every time you need to check the current working directory, but there's a better way. Whenever you run the cd command successfully, the new working directory is stored in the environmental variable $PWD (Present Working Directory). Note that this variable is in uppercase letters, unlike the pwd command. So, you could display the value of $PWD using echo, as you can see in Listing 3.

Listing 3. Display $PWD
1

2

# echo $PWD

# /home/anthony

Doesn't seem much easier than running that pwd command you saw earlier, does it? Still, it's helpful to know that your directory is stored in a variable. Here's why: You can display the value of $PWD as part of the shell prompt.
Visit your parents
If you run the ls command using the -a flag, you can see an entry for . (dot) and another for .. (dot-dot). The single dot represents the current directory. The two dots are for the parent directory—the one immediately above the directory you're in.

Using the parent directory is handy when you want to go up a level via cd. Listing 7 shows how.

Listing 7. Using the cd command to go to the parent directory (dot-dot)
1

2

/var/spool/mqueue > cd ..

/var/spool >

You can then head down to a new subdirectory (see Listing 8 ).

Listing 8. Using cd to go to a subdirectory
1

2

/var/spool > cd mail

/var/spool/mail >

Or, you could do all of that in a single command, as you see in Listing 9.

Listing 9. Branch to branch in one command
1

2

/var/spool/mqueue > cd ../mail

/var/spool/mail >

You can even jump up a couple of levels, and then down a couple, as shown in Listing 10.

Listing 10. Jump through branches
1

2

/usr/IBM/WebSphere/AppServer/profiles > cd ../../PortalServer/log

/usr/IBM/WebSphere/PortalServer/log >
Call home, tilde
You may want to view or work on files in your home directory. If you're in some other directory, there's no need to go home first or to type the full directory path. Just use the tilde character. In Listing 13, I make a copy of my .profile in my home directory, all from the comfort of somewhere else.

Listing 13. Tilde shortcut for $HOME
1

/usr/IBM/WebSphere > cp ~/.profile ~/.profile.save

Remote access to your neighbour's home
You can also use tilde to list or work with files in another user's home directory (if your permissions allow it). To do this, just use tilde followed by the user's login name, as Listing 14 shows.

Listing 14. Tilde is everyone's HOME
1

/home/anthony > cp ~john/.profile ~john/.profile.save

This is safer than guessing the user's home directory and easier than looking it up in /etc/passwd.

Dashing back
Quite often, you need to change directory only to run a command or two, and then return to the directory you were in previously ($OLDPWD). To do that, use the cd dashback. That's cd followed by a dash (cd -). In Listing 15, notice how the $PS1 shell prompt displays the new directory each time I run cd.

Listing 15. Return to previous directory
1

2

3

/home/anthony > cd /usr/sys/inst.images

/usr/sys/inst.images > cd -

/home/anthony >
 
Joined
Nov 15, 2016
Messages
214
Likes
95
#2
Here's some basics. In case they take something down.

Linux/Mac OSX
Take this list of commands and create index cards with the names on the left on one side, and the definitions on the other side. Drill them every day while continuing with the lessons in this appendix.

pwd
print working directory
hostname
my computer's network name
mkdir
make directory
cd
change directory
ls
list directory
rmdir
remove directory
pushd
push directory
popd
pop directory
cp
copy a file or directory
mv
move a file or directory
less
page through a file
cat
print the whole file
xargs
execute arguments
find
find files
grep
find things inside files
man
read a manual page
apropos
find what man page is appropriate
env
look at your environment
echo
print some arguments
export
export/set a new environment variable
exit
exit the shell
sudo
DANGER! become super user root DANGER!
Windows
If you're using Windows then here's your list of commands:

pwd
print working directory
hostname
my computer's network name
mkdir
make directory
cd
change directory
ls
list directory
rmdir
remove directory
pushd
push directory
popd
pop directory
cp
copy a file or directory
robocopy
robust copy
mv
move a file or directory
more
page through a file
type
print the whole file
forfiles
run a command on lots of files
dir -r
find files
select-string
find things inside files
help
read a manual page
helpctr
find what man page is appropriate
echo
print some arguments
set
export/set a new environment variable
exit
exit the shell
runas
DANGER! become super user root DANGER!
Drill, drill, drill! Drill until you can say these phrases right away when you see that word. Then drill the inverse, so that you read the phrase and know what command will do that. You're building your vocabulary by doing this, but don't spend so much time you go nuts and get bored.
 

Usury

Platinum Bling
Platinum Bling
Joined
Apr 1, 2010
Messages
4,110
Likes
3,261
#3
Oh the good ole days of DOS 3.3.

Really DOS 5.0. Come to think of it DOS 5.0 may be the only time in history the Microshaft released a major OS upgrade that was bug-free. There was no DOS 5.1 or 5.01, just DOS 5.0.
 

Usury

Platinum Bling
Platinum Bling
Joined
Apr 1, 2010
Messages
4,110
Likes
3,261
#4
COPY CON>AUTOEXEC.BAT
SMARTDRV.EXE
MOUSE.COM
SET SOUND=ADLIB
PROMPT $P$G
PATH C:\DOS
^Z
 

Goldhedge

Moderator
Site Mgr
Sr Site Supporter
Joined
Mar 28, 2010
Messages
30,653
Likes
37,524
Location
Planet Earth
#5
I just paid $30 a week or so ago for an online python course by Udemy.

Started it today. Pretty good so far. Video instruction.

It helps to know math.

I'll check out the link. The more resoources one has the better.
 

Goldhedge

Moderator
Site Mgr
Sr Site Supporter
Joined
Mar 28, 2010
Messages
30,653
Likes
37,524
Location
Planet Earth
#6
Here's one on Git
 
Joined
Nov 15, 2016
Messages
214
Likes
95
#7
Having some sort of mental block with the "object oriented programming". I got the var defines and the functions. Now I'm struggling with the syntax of the python language ( IDE?) with classes. I was digging it until they changed the syntax completely. Might as well just learn Java too. They say that learning the higher level languages is detrimental to learning the lower level machine code though I don't know. Maybe an intro?



:edited for spelling, clarity and non drunkenness
 
Last edited:

Alton

Gold Member
Gold Chaser
Joined
Apr 1, 2010
Messages
2,912
Likes
4,888
Location
Michiana
#8
Having some sort of mental block with the "object oriented programing". I got the var defines and the functions. Now I',m struggling with the syntax of the python language ( IDE?) with objects. I was digging it untill they changed the syntax completly. Might as well just learn java too. They say that learning the higher level languages is detrimental to learning the lower level machine code though I don't know. Maybe an intro?
Now that programmers have a better handle on Java it's become more useful, more secure and rather ubiquitous it would be time well spent to learn at least it's basics. The real trick now is to make the time available to learn it.
 

oldgaranddad

Gold Member
Gold Chaser
Sr Site Supporter
Joined
Feb 21, 2012
Messages
3,582
Likes
5,235
Location
On the top shelf.
#9
I just paid $30 a week or so ago for an online python course by Udemy.

Started it today. Pretty good so far. Video instruction.

It helps to know math.

I'll check out the link. The more resoources one has the better.
I've taken several courses on Udemy. Wait until they have their $9.99 sales. I'm taking the Go language course now and brushed up on my python too. Well worth the $10 a piece.

The best course on udemy I took was a Terraform course.
 

solarion

Gold Member
Gold Chaser
Site Supporter ++
Joined
Nov 25, 2013
Messages
5,047
Likes
7,596
#10
Hafta check out that Udemy thingy. A guy can make a mint coding crypto wallets with just a dash of know how.