퍼미션(권한)이란?

Owner

Group

Other

Owner와 Group은 파일소유자자신과 자신이 속한그룹. Other은 제3자, 웹사이트 방문객은 제3자로 nobody로 취급.

r

w

x

r

w

x

r

w

x

r은 파일 읽기(4), w는 파일 쓰기(2), x는 파일 실행(1)

7

5

5

파일소유자는 그것을 읽고 쓰고 실행시킬 수 있지만, 제3자는 읽고 실행만 시킬 수 있다.

7

7

7

제3자도 쓰기 권한이 주어진다.

*.html  *.cgi, *.pl *.txt등의 파일은 업로드시 반드시 ascii로 하고 나머지 그림(*.gif *.jpg)이나 자바 애플릿(*.class), 실행파일(*.exe *.zip *.rar)등은 binary mode로 업로드 할 것.

   리눅스 기본명령어

명령어

사 용 법

login

사용자 인증과정

리눅스 시스템은 기본적으로 multi-user 개념에서 시작하였기 때문에 시스템을 이용하기 위해서는 반드시 로그인을 하여야 합니 다. 로그인은 PC 통신에서도 많이 사용되어져 왔기 때문에 그 개 념  설정에 그다지 어려움이 없을 것입니다. 흔히 말하는 ID를 입력하는 과정입니다. 

passwd

패스워드 변경

리눅스, 특히 인터넷의 세계에서는 일반 컴퓨팅 상황에 비하여 훨씬 해킹에 대한 위험이 높습니다. 패스워드는 완성된 단어 보다는 단어 중간에 숫자나 키보드의 ^, #, ' 등과 같은 쉽게 연상 할 수 없는 기호를 삽입하여 만들어 주는 것이 좋습니다

du

하드사용량 체크(chkdsk)

자신의 하드공간을 알려면
# du
특정 디렉토리의 사용량을 알려면
# du -s diretory_name

ls

파일 리스트 보기(dir)

F : 파일 유형을 나타내는 기호를 파일명 끝에 표시
    (디렉토리는 '/', 실행파일은 '*', 심볼릭 링크는 '@'가 나타남).
l  : 파일에 관한 상세 정보를 나타냅니다.
a : dot 파일(.access 등)을 포함한 모든 파일 표시.
t  : 파일이 생성된 시간별로 표시
C : 도스의 dir/w명령과 같 이 한줄에 여러개의 정보를 표시
R : 도스의 dir/s 명령과 같이 서브디렉토리 내용까지.

(예)
# ls -al  
# ls -aC
# ls -R

cd

디렉토리를 변경

# cd cgi-bin     : 하부 디렉토리인 cgi-bin으로 들어감.
# cd  ..             : 상위디렉토리로 이동
# cd 또는 cd ~  : 어느곳에서든지 자기 홈디렉토리로 바로 이동
# cd /webker     : 현재 작업중인 디렉토리의 하위나 상위 디렉토리가
                          아닌 다른 디렉토리(webker)로 이동하려면 /로
                          시작해서 경로이름을 입력하면 된다.

cp

화일 복사(copy)

# cp index.html index.old
     : index.html 화일을 index.old 란 이름으로 복사.

# cp /home/test/*.*  .
     : test 디렉토리내의 모든 화일을 현 디렉토리로 복사.

mv

파일이름(rename) / 위치(move)변경

# mv index.htm index.html
     : index.htm 화일을 index.html 로 이름 변경

$ mv file  ../main/new_file
     : 파일의 위치변경

mkdir

디렉토리 생성

# mkdir download  : download 디렉토리 생성

rm

화일삭제

# rm test.html : test.html 화일 삭제
# rm -r <디렉토리> : 디렉토리 전체를 삭제
# rm -i a.*
     : a로 시작하는 모든 파일을 일일이 삭제할 것인지 확인하면서 삭제 

rmdir

디렉토리 삭제

# rmdir cgi-bin : cgi-bin 디렉토리 삭제

pwd

현재의 디렉토리 경로를 보여주기

pico

리눅스용 에디터

put

ftp 상태에서 화일 업로드

> put  guestbook.tar.gz

get

ftp 상태에서 화일 다운로드

> get  guestbook.tar.gz

mput 또는 mget

여러개의 화일을 올리고 내릴때 (put,get과 사용법동일)

chmod

화일 permission 변경

리눅스에서는 각 화일과 디렉토리에 사용권한을 부여.

예) -rwxr-xr-x   guestbookt.html
rwx  :처음 3개 문자 = 사용자 자신의 사용 권한
r-x  :그다음 3개 문자 = 그룹 사용자의 사용 권한
r-x  :마지막 3개 문자 = 전체 사용자의 사용 권한

읽기(read)---------- 화일 읽기 권한
쓰기(write)---------- 화일 쓰기 권한
실행(execution)---------- 화일 실행 권한
없음(-)---------- 사용권한 없음

명령어 사용법
chmod [변경모드] [파일]

# chmod 666  guestbook.html
     : test.html 화일을 자신에게만 r,w,x 권한을 줌

# chmod 766  guestbook.html
     : 자신은 모든 권한을 그룹사용자와,전체사용자에게는
       읽기와 쓰기 권한만 줌

alias

" doskey alias" 와 비슷하게 이용할 수 있는 쉘 명령어 alias는 말그대로 별명입니다. 사용자는 alias를 이용하여 긴 유 닉스 명령어를 간단하게 줄여서 사용할 수도 있습니다.
이들 앨리어스는 [alias ls 'ls -al'] 같이 사용하시면 되는데, 한 번 지정한 alias를 계속해서 이용하시려면, 자신의 홈디렉토리에 있는
.cshrc(Hidden 속성)을 pico등의 에디터를 이용하여 변경시 키면 됩니다.

cat

파일의 내용을 화면에 출력하거나 파일을 만드는 명령( 도스의 TYPE명령)

# cat filename

more

cat 명령어는 실행을 시키면 한 화면을 넘기는 파일일 경우 그 내용을 모두 볼수가 없다. 하지만 more 명령어를 사용하면 한 화면 단위로 보여줄 수 있어 유용.

# more <옵션>
옵션은 다음과 같습니다.

Space bar : 다음 페이지
Return(enter) key : 다음 줄
v : vi 편집기로 전환
/str : str 문자를 찾음
b : 이전 페이지
q : more 상태를 빠져나감
h : 도움말
= : 현재 line number를 보여줌

who

현재 시스템에 login 하고 있는 사용자의 리스트를 보여줍니다.

# who

whereis

소스, 실행파일, 메뉴얼 등의 위치를 알려줍니다

# whereis perl : perl의 위치를 알려준다

vi,
touch,
cat

새로운 파일을 만드는 방법

# vi newfile :  vi 편집기 상태로 들어감
# touch newfile : 빈 파일만 생성됨
# cat > newfile  : vi 편집기 상태로 들어감, 문서 작성후 Ctrl+D로 빠져나옴

cat,
head,
tail

파일 내용만 보기

# cat filename         : 파일의 내용을 모두 보여줌
# head -n filename : n줄 만큼 위세서부터 보여줌
# tail -n filename     : n줄 만큼 아래에서부터 보여줌

 

   압축명령어 사용법

압축 명령어

사 용 법

tar .tar, _tar로 된 파일을 묶거나 풀때 사용하는 명령어
(압축파일이 아님)

# tar cvf [파일명(.tar, _tar)] 압축할 파일(또는 디렉토리): 묶을때
# tar xvf [파일명(.tar, _tar)]  :  풀 때
   (cf) cvfp/xvfp 로 하면 퍼미션 부동 
compress 확장자 .Z 형태의 압축파일 생성

# compress    [파일명]     : 압축시
# uncompress [파일명]    : 해제시
gzip 확장자  .gz, .z 형태의 압축파일 생성

#  gzip     [파일명]    : 압축시
#  gzip -d [파일명]   : 해제시
기타 .tar.Z
이것은 tar로 묶은 후에 compress를 사용하여 압축한 것으로 uncompress를 사용해서 압축을 푼 다음,
다시 tar를 사용해서 원래의 파일들을 만들어내면 됩니다.
아니면 다음과 같이 한 번에 풀 수도 있다.
# zcat  [파일명].tar.Z  : 해제시

.tar.gz또는 .tar.z
# gzip -cd [파일명]    : 해제시

.tar.gz 또는 .tar.z .tgz
gzip을 사용해서 푼 다음 다시 tar를 사용해서 원래 파일을 만들어 낼 수 있으나,
하지만 다음과 같이 하면 한 번에 처리를 할 수 있다.

# gzip -cd 파일.tar.gz | tar xvf -  또는
# tar xvzf 파일.tar.gz
# tar xvzf 파일.tgz

 

   리눅스 필수명령어

Linux/Unix 명령어

설 명

MS-DOS 비교

./x

x 프로그램 실행
(현재 디렉토리에 있는 것)

x

/

이전에(↑) / 다음에(↓) 입력했던 명령어

doskey

cd x (또는 cd /x)

디렉토리 X로 가기

cd

cd .. (또는 cd ../ 또는 cd /..)

한 디렉토리 위로 가기

cd..

x 다음 [tab] [tab]

x 로 시작하는 모든 명령어 보기

-

adduser

시스템에 사용자 추가

/

ls (또는 dir)

디렉토리 내부 보여주기

dir

cat

터미널 상의 텍스트 파일 보기

type

mv x y

파일 x를 파일 y로 바꾸거나 옮기기

move

cp x y

파일 x를 파일 y로 복사하기

copy

rm x

파일 지우기

del

mkdir x

디렉토리 만들기

md

rmdir x

디렉토리 지우기

rd

rm -r x

디렉토리 x를 지우고 하위도 다 지우기

deltree

rm p

패키지 지우기

-

df (또는 df x)

장치 x의 남은 공간 보여주기

chkdsk ?

top

메모리 상태 보여주기(q는 종료)

mem

man x

명령어 x에 관한 매뉴얼 페이지 얻기

/

less x

 텍스트 파일 x 보기
(리눅스에서는 더 많은 필터 적용 가능)

type x | more

echo

어떤 것을  echo 화면에 인쇄한다.

echo

mc

UNIX를 위한 노턴 커맨더

nc

mount

장치 연결(예: CD-ROM, 연결을 해제하려면 umount)

-

halt

시스템 종료

-

reboot ([ctrl] + [alt] +[del])

시스템  다시 시작하기

[ctrl] + [del] + [del]

    고급명령어

 고급 명령어

 

chmod <권한> <파일>

파일 권한(permissions) 변경

ls -l x

파일 x의 자세한 상황을 보여줌

ln -s x y

 x에서 y로 심볼릭 링크를 만들어 줌

find x -name y -print

디렉토리 x안에서 파일 y를 찾아서 화면에 그 결과를 보여줌

ps

지금 작동중인 모든 프로세스들을 보여줌

kill x

 프로세스 x를 종료 (x는 ps 명령으로 알 게 된 PID)

[alt] + F1 - F7

 터미널 1-7까지 바꾸기 (텍스트 터미널에서; F7은 X-윈도우(시작될때))

lilo

 부트 디스크를 만듦

 

용어

 

symlink

다른 파일이나 디렉토리로 심볼릭 링크. 윈도유98의 바로가기 같은 것

shell script

여러 명령어들을 차례로 수행하게 한 것. MS-DOS의 배치 파일 같은 것

How to uninstall and remove Apache2 on Ubuntu or Debian

It turns out that uninstalling Apache2 web server is not as straightforward as installing it. You will need to remove Apache2 package itself, as well as other dependent packages and its associated configurations. Here is how you remove Apache2 cleanly on Ubuntu and Debian.

The first step is to stop any running instance of Apache2, because Apache2 will not be properly removed while it is running.

$ sudo service apache2 stop

 

Then uninstall Apache2 and its dependent packages. Use purge option instead of remove with apt-get command. The former option will try to remove dependent packages, as well as any configuration files created by them. In addition, use autoremove option as well, to remove any other dependencies that were installed with Apache2, but are no longer used by any other package.

$ sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
$ sudo apt-get autoremove

 

Finally, check if there is any configuration files or manual pages belonging to Apache2, which are still not removed.

$ whereis apache2
apache2: /etc/apache2

In this example, /etc/apache2 directory still exists. Since this directory (as well as any configuration files in it) is no longer necessary, go ahead and remove it manually.

$ sudo rm -rf /etc/apache2

'Linux' 카테고리의 다른 글

how can I add an application to the "open with" menu ubuntu 11.10  (0) 2015.12.29
리눅스 웹 한글깨짐  (0) 2015.10.16
alias를 이용한 단축명령 만들기  (0) 2015.10.11
vim syntax, indent, linenumber 설정  (0) 2015.06.25
Linux commands  (0) 2015.06.24

 

 

'Server > Apache' 카테고리의 다른 글

Tomcat manager unauthorized  (0) 2015.06.26
라즈베리파이 서버 활용 강좌 : 아파치 웹서버 설치  (0) 2015.06.24

출처:http://www.rasplay.org/?p=72

지난 번 포스트에서는 Raspberry Pi에 Debian계열인 Raspbian을 설치 해 보았습니다.

오늘은 설치한 Raspbian에 Web Server 를 올려보려고 합니다.

Rasbian에 Web Server 올리기
(Apache + Mysql + PHP5 + phpmyadmin )

Putty 를 이용하여 SSH 로 산딸기에 접속을 합니다.  

산딸기 접속 후, 가장 먼저 아파치를 설치 진행 합니다.

Apache, MySQL, PHP, PHP-APC 순서로 설치합니다.

sudo apt-get install apache2

자 이제 apache2 가 정상작동을 하는지 서버로 접속합니다.

브라우저에서 http://localhost 로 접속 합니다.

위처럼 It Works 라는 문구가 보이신다면 apache2 가 정상적으로 작동 중인 것입니다. 

apache2의 정상 작동이 확인 됐으니 다음은 DB를 생성관리하는 MySQL 을 설치 해 볼까요 

sudo apt-get install mysql-server mysql-client

sudo apt-get install php5-common php5 libapache2-mod-php5

” sudo vim /var/www/phpinfo.php ” 를 입력 후,  php정보를 볼 수 있도록 코딩을 합니다.  

<?
phpinfo();
?> 

vim 을 나올 수 있도록 아래처럼 ” w(저장)q(나가기) ” 명령어를 입력합니다.

apache2에서 PHP가 정상적으로 구현이 되는지 볼까요 ?

” http://도메인/phpinfo.php “ 를 입력하여 php작동 여부를 확인 합니다.

sudo apt-get install phpmyadmin

저희는 apache2 가 설치되어 있으니 “apache2″ 를 체크 후 OK 합니다.

MySQL에 접속 할 수 있는 phpmyadmin 에 접속 할 패스워드를 입력합니다.

자 이제 phpmyadmin 이 정상적으로 설치되었는지 테스트를 합니다.

http://도메인/phpmyadmin

휴… 모든 웹서버를 구동할 준비가 되었습니다.

이제 여러분께서 원하시는 멋진 홈페이지를 작업하시면 되겠습니다.

Tip: apache2 server의 구현은 /var/www 위치에 설치 하셔야만 작동합니다.


'Server > Apache' 카테고리의 다른 글

Tomcat manager unauthorized  (0) 2015.06.26
아파치 톰캣이란??  (0) 2015.06.24

Setting Up VNC

While the Raspberry Pi does provide a superb picture over hdmi, there are a lot of scenarios where one might not need a display, and connecting remotely via VNC will suffice.  For instance, any programming could be done remotely, while still having access to the physical hardware.  It's also particularly useful when the TV is in use and getting it back to "play on" isn't an option.

EDIT 25/04/2012: Ive now identified how to enable SSH automatically - see below (thanks Abishur!!)

EDIT 20/08/2012: I've worked out how to start VNC automatically on bootup - see my other post here http://myraspberrypiexperience.blogspot.co.uk/2012/08/start-vnc-automatically.html

Pre-requisites
As a bit of background, I'm using the latest Debian image (19/04/2012) and I'm connecting from my Windows 7 laptop.  To connect I've installed UltraVNC on my laptop - you can download a free copy from here:
UltraVNC Downloads Page

Now, once  the VNC server is up and running on the Pi you can VNC from your laptop into your Pi without doing anything on the Pi first.  If you've just turned it on however, you'll need to first start the VNC server on the Pi.  And if you're using this as a truly headless box, that can be a little difficult.  To get around this I've used the PuTTY SSH client, which you can download here:
PuTTY Downloads Page

The last thing you need to know is the IP Address.  If you've configured your Pi with a static IP Address, that's great.  If you have access to your router to look this up that's fine too.  You might however be in a situation where you have no way to look up the IP Address (like me) - for this I needed a utility to scan the network for all machines.  For this I used:
Advanced IP Scanner
This will scan your network listing all devices it can find.  Simply look through the list of devices and find your Rashberry Pi. It'll have a fairly obvious name, like "RaspberryPi".

Alternatively, if you have access to your wireless router, you might be able to connect to this and see a list of all devices that have connected to it, including your Raspberry Pi.  As each wireless router differs, I'll leave this up to you to figure out :-)

Starting SSH on the Pi
First off - what is SSH?  It's a process that can be run in Linux that will allow you to access your Raspberry Pi remotely.  You'll be able to run anything that you would normally run from the command line on your Raspberry Pi, remotely from an SSH client - i.e. Putty.  #

I've found that the latest Debian image doesn't come with SSH enabled by default.  If you have a monitor and keyboard attached, once you've logged in you can start SSH by typing sudo /etc/init.d/ssh start as shown below:



Now, the idea of SSH is that we can connect remotely without a display, so you don't necessarily want to have to do this every time you boot up. 



EDIT 28/01/2013: There are two approaches to enabling SSH.


First option
For older images like Debian there is a file in place that can be used to do this - boot_enable_ssh.rc.  This file is on the boot partition of the SD card - i.e. the partition that can be read by Windows.  So - put the card into your PC card reader and open it up:


Now rename boot_enable_ssh.rc to boot.rc:
 


Once you've done this put the card back into the Pi and boot up - SSH will now be automatically enabled.
 


Second option
If you're using a newer distro like Raspbian Wheezy, when you first boot up the image you'll be taken to a config screen. From here you'll be able to enable SSH (along with a number of other useful options!).



Connecting via SSH
As mentioned above, to be able to connect into the Pi using VNC you first need to start the VNC server, and without a display connected you need to start this remotely.  SSH provides this mechanism.  To start with, we take our SSH Client - PuTTY.  Once you've downloaded it, simply launch it - it's a standalone exe - you'll be presented with this screen:

Simply type in Raspberry Pi IP Address in the Host Name field that you found earlier and click open.  Once Putty has connected to the SSH process running on the Pi, a terminal window will pop up and you'll be prompted with a login.  

I still have my UN & PW set to pi and raspberry, so just typed that in.  Once logged in I'm taken to the standard terminal prompt.  From here you can run pretty much any command you want on the Raspberry Pi.

Setting up VNC Server via SSH
Now that you're connected, you need to start the VNC server.  If this is the first time you're doing this, you'll also need to install VNC first.  I've assumed you'll have internet access as this will be required to install this.  To do this, run the following command:
sudo apt-get install tightvncserver

As mentioned above, the Putty SSH Client lets you run commands on your Pi directly, so by doing this you're installing a VNC application on your Pi.

NOTE: during the install you'll be prompted to install without verification - type y here. 

Once installed, you'll need to start the VNC server.  The command I've used here is vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565:

This will start the VNC server process on the Pi.  What this means is that it will start a virtual X session (a virtual instance of the Raspberry Pi GUI) on your Pi, in a very similar way to when you run startx when your Pi is connected to a display.  When you VNC into your Pi you will be connecting to this X session.

So - the important port of this command is :1.  This defines the port that the VNC process will be started on - you can make this whatever you want, but will need to remember it to ensure you connect to the right port.  You'll see more details on this below.  As for the resolution (-geometry) this will be the resolution that the X session will run under - you can make this pretty much whatever you want 

The first time you launch VNCServer you'll be prompted for a password - you'll need this to connect in using VNC.

You'll also be asked for a view-only password (optional).  When providing the password via VNC the remote use will only have read-only access to the Raspberry Pi:


Connecting via UltraVNC 
Once VNC server has been started the only thing left to do is connect.  Start up UltraVNC, type in the IP Address (or machine name) with a port of 1 and connect.  
NOTE:  This port is the port you used when starting the VNC process above:

And that's it - connected!


EDIT 06/05/2012: I've found out there are two potential desktops you might see, and this is determined by the user that launches vncserver (or startx for that matter).  Using sudo will give you the LXDE desktop above.  Launching it without sudo will give the intended Raspberry Pi desktop as shown below.
 


'Linux > RaspberryPi' 카테고리의 다른 글

Raspberry Pi – Enabling Telnet  (0) 2015.06.29
Raspberry Pi에서 Java 설치하기!  (0) 2015.06.25
시작시 Auto running programs  (0) 2015.01.03
(cpp)wiringpi활용  (0) 2015.01.03
(python)GPIO 끄기: GPIO cleanup()  (0) 2015.01.03

Command Prompt - How to Use Basic Commands

After we have shared how to open and customize Command Prompt, it is time to see how to use it to perform basic operations. This article will show how to execute commands like changing the working directory, viewing content of a directory, creating and renaming folders, copying, deleting files and folders, and how to launch any application from Command Prompt. Also, it will show how to get help when using the tool.

How to Navigate Between Folders

The first command from the list is CD (Change Directory). This command enables you to change the current directory (or folder).

The command CD\ takes you to the top of the directory tree.
Let's see how it works. After you open the Command Prompt, type cd\ and press Enter. You will see that it takes you to the top of the directory tree (in this case to the 'C:' drive).

NOTE: Command Prompt is not case sensitive, meaning that commands can be typed with capital letters, lowercase or a combination of them(so cd, CD or Cd will all work in the same way).

Command Prompt

Now you are working on the 'C:' drive. If you need to go to a specific folder from this drive just type CD DIRECTORYNAME. The subdirectory names are separated by \. For example when you need to access the System32 folder that is located on 'C:\Windows' just type cd windows\system32\, as shown below, and then press Enter.

Command Prompt

When you need to go to one folder up, use the cd.. command. Let's assume that you want to go back to the Windows folder. Type cd.. and press Enter. You will notice that your current directory has changed to 'C:\Windows'.

Command Prompt

How to Access a Certain Drive

To access another drive just type the drive letter followed by ':'. For example, we wanted to change the drive from 'C:' to 'D:'. We have typed d: and then pressed Enter.

Command Prompt

To change the drive and the directory at the same time, use the cd command followed by the/d switch. The parameter is used to change the current drive to a specific folder from other partition. For example, now you are on the 'D:' drive and you want to go back to the 'C:'drive directly to the Windows folder. Type cd/d C:\Windows and press Enter, as you can see in the following image.

Command Prompt

Note: By typing the drive letter you automatically move to your most recent location in that drive. For example if you are on 'd:' drive and type cd c:\windows nothing happen. But, if you type 'c:' then the working will change to c:\windows (assuming that it was the last directory you worked with on c: drive).

How to View the Content of a Folder

You can view the content of a folder by using a simple command called DIR. To test, we've created on the 'd:' drive a folder named 7tutorials with several files and subfolders.

Command Prompt

Last time the working directory was 'c:\Windows'. We will go to the folder mentioned above by using the command cd/d d:\7tutorials. To view the content of the folder we will type DIRand press Enter. A list of the files and folders contained by it is displayed, together with some details about these files and folders (size, the date and time of the last modification).

Command Prompt

How to Create a New Folder

You can make a new directory using the MKDIR (Make Directory) command. The syntax of this command is MKDIR directory name.

Let's say we need to create a new folder called 7tutorials_v1 that will be placed in the'd:\7tutorials' folder. We will type mkdir 7tutorials_v1 and then we press Enter, as shown below.

Command Prompt

To test if it worked, we will use again the dir command. The newly created folder appears in the list.

Command Prompt

Note: Don't forget that all these commands depend on the current location in the Command Prompt. So if you are at 'C:' and type MKDIR test, a new folder will be created in the 'C:'drive.

Another way to create a directory, that doesn't involve being on the desired folder, is to type the complete the path of the folder. For example, you are working on the 'D:' drive and you want to create a new folder on 'C:' drive called other_stuff. Just type mkdir c:\other_stuff and then press Enter.

Command Prompt

When you need to create a folder with subfolders at the same time you can use the MKDIR foldername\subfolder command . For instance, if we type mkdir 7tutorials_tests\beta\test1three folders will be created: 7tutorials_tests, beta, test1, in a tree-like structure.

Command Prompt

How to Rename Files and Folders

To rename files and folders you need to use the REN (Rename) command.

For folders just type ren foldername newname. For example if we want to rename the7tutorials_v1 folder to 7tutorials_final we type ren 7tutorials_v1 7tutorials_final and then pressEnter.

Command Prompt

To rename a file, use the same command, like this: ren filename.extension newname.extension. For example, to rename the 7tutorials_picture.jpg file to picture1.jpg we have to use the ren 7tutorials_picture.jpg picture1.jpg command.

Command Prompt

Copy Files and Folders

The Copy command allows you to copy files from one location to another. To use this command you have to type copy location\filename.extension location\newname.extension.

For example, let's use this command to copy the picture1.jpg file from the 7tutorials folder located on 'd:' drive to the 'd:\7tutorials\7tutorials_tests\ folder. To make things more interesting we want the file to be named testing_picture1.gif. We will write the command copy d:\7tutorials\picture1.jpg d:\7tutorials\7tutorials_tests\testing_picture1.giffollowed by Enter. You will receive a confirmation of the operation, as you can see below.

Command Prompt

If you are copying within the same directory you don't have to put the path in command. As an example, we need to copy Notes.txt from 'd:\7tutorials' in the same folder, only under a different extension, let's say Notes.doc. We will just type the command copy Notes.txt Notes.doc.

Command Prompt

To copy a folder and its content from a location to another we will use the XCOPY command followed by the /s / i operators. Let's assume that we need to copy a folder from'd:\7tutorials' to c:\backup_7tutorials. We have to type the xcopy /s /i d:\7tutorials c:\backup_7tutorials command and then press Enter. The '/s' parameter will ensure that all the directories and subdirectories will be copied, except the ones that are empty. The '/i'parameter will create a new directory if the destination folder doesn't exist and you copy multiple files.

Command Prompt

Delete Files and Folders

The DEL (Delete) is used to delete files within the directories you've created.

To delete all the files from a directory you have to type del directory name. Let's try this command. For example, from the directory 7tutorials located on the d: drive, we will delete all files from the 7tutorials_tests folder by typing the commanddel 7tutorials_tests. You need to confirm the delete process by typing the letter y and then press Enter.

NOTE: To delete hidden files you have to use /h parameter.

Command Prompt

If we need to delete a single file we will use the DEL command folowed by the filename. We need to delete the file Notes.txt from 'd:\7tutorials'. We will type in the del Notes.txtcommand followed by Enter.

Command Prompt

Here is a list of useful DEL combinations that is worth mentioning:

  • DEL *.DOC - delete all files with the DOC extension(you can use any file extension necessary, DOC is the example I used);
  • DEL Test*.* - delete all files beginning with Test;
  • DEL *.* - delete ALL files from the current directory.

The DEL command cannot be used to delete directories, therefore we will use another command to remove any empty directory: RD (Remove Directory). Previously we've deleted all the files from the 7tutorials_tests folder. It's time to delete it by typing RD 7tutorials_tests.

Command Prompt

Launch an Application from Command Prompt

To run a program from the Command Prompt, you need only to navigate to the directory that contains the executable and simply type in the program name. For example, if we want to launch Paint using Command Line, we have to go to C:\Windows\System32 and there we will find the executable called mspaint.exe. Let's see how this operation can be done, if we are onD:\7tutorials. First off all we have to change the working directory to the application's folder by typing cd/d c:\windows\System32\. Then we just write mspaint.exe and press Enter. Both commands can be seen in the capture below.

Command Prompt

How to Use Help in Command Prompt

To access help in Command Prompt you just have to type the help command and then pressEnter. A list off all available commands will be displayed, as you can see below.

Command Prompt

If a certain command interests you type help followed by the name of the command. Another way to do the same thing is to type command_name followed by the /? parameter. To test, use help cd or cd/? to display information about the cd command. In the picture below you can view the result.

Command Prompt

Conclusion

The Command Prompt remains a very powerful tool for any computer user who is willing to get his hands dirty and learn a bit. We hope this article was useful in helping you learning the basics about running commands in the Command Prompt. If you have any questions about it, don't hesitate to leave a comment.


 출처:http://wookoa.tistory.com/55

■ 'javac'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.

 

자바를 설치하고 환경변수를 설정하는 과정에서, 그 과정이 엇갈리거나 꼬이게 되면 흔히 볼 수 있는 에러 화면이다. 커맨드 입력창에 'javac' 명령을 날리면 볼 수 있는 메세지다."'javac'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다."본 포스팅에서는 이러한 에러를 해결하기 위한 방법을 소개한다.


 

 

 

 

 

 


 

 

 

자바 설치를 하고 열심히 환경변수를 설정한 뒤, 커맨드 입력창에 'javac' 명령을 날리자마자 아래와 같은 메세지를 받는다면 매우 당황스럽다. 보통은 환경변수 설정하는 단계에서 오타에 의한 실수인 경우도 존재하지만, Windows 7에서 Windows XP와 같은 방식으로 환경변수를 설정하게 되면 많이 발생하기도 한다.

 

 

 

만약 사용자 변수 PATH가 존재하지 않는다면 새로 생성한다. 이때 확인해야될 부분은 크게 두가지다. 첫번째는 환경 변수가 제대로 작성되었는지 검토해야 한다. 두번째는 JDK가 제대로 설치되었는지 확인한다. 설치한 소프트웨어가 JRE가 아닌, JDK가 확실하다면 javac.exe는 분명히 설치된 것이다.

 

인터넷에서 환경 변수를 설정하는 방법은 여러가지 존재한다. 하지만, 가장 교과서적인 방법은 JAVA_HOME 생성, CLASSPATH 생성, Path 수정 이 세 가지의 종류가 있다. 환경 변수 설정이 모두 끝났음에도 javac를 인식하지 못하고 위와 같은 메시지가 출력된다면, PC가%JAVA_HOME%을 인식하지 못하는 경우를 의심해 볼 필요가 있다. 이를 해결하기 위한 방법은 간단하다.

 

 

 

첫번째로 사용자 변수 PATH를 편집하여 변수 값 제일 앞에 %JAVA_HOME%\bin 설정한다. 만약 사용자 변수 PATH가 존재하지 않는다면 새로 생성한다.

 

 

 

두번째로 시스템 변수 Path의 %JAVA_HOME%을 실제 JDK 설치경로를 직접 설정한다.

 

 


Picture of How to Build an 8-Bit Computer
Building an 8-bit TTL computer sounds like a daunting and complicated task, or at least it did to me when I started out on my journey to understand the architecture of a basic CPU. When it comes down to it, a CPU is fairly simple in operation once you learn the fundamentals behind all of its processes. This project is intended to help anyone interested in building their own computer and gaining the wonderful knowledge that comes along with the process. Don't be afraid to try, you can only learn.

This project will start off by describing the basics of electronics. After that, the fundamentals of binary and boolean logic will be described. Lastly we will then move onto the function of the various parts of a simple-as-possible computer (with a few modifications) as described in Malvino's text Digital Computer Electronics. This means that the end product of this Instructable will be a computer that you can program with a unique instruction set. This project also leaves many of the design aspects of the computer up to you and serves as a guide for building your own computer. This is because there are many ways to approach this project. If you already have a sound understanding of boolean logic and the workings of binary feel free to skip to the meat of the project. I hope that you all enjoy and get something out of a build like this, I know that I sure did.

For this project you will need:

1.) A power supply
2.) Breadboards + lots of wires
3.) LED's for output
4.) Various logic IC's (discussed later)
5.) Free time
6.) A willingness to mess up and learn from mistakes
7.) A lot of patience

Optional (but very useful):

1.) Oscilloscope
2.) Digital multimeter
3.) EEPROM programmer
4.) Sonic screwdriver

Useful Links for a Project Like This:

Digital Computer Electronics: 
http://www.amazon.com/Digital-computer-electronics-Albert-Malvino/dp/007039861
TTL Cookbook: http://www.amazon.com/TTL-Cookbook-Understanding-Transistor-Transistor-Integrated/dp/B0049UUV38
 
Remove these adsRemove these ads by Signing Up

Step 1: What Is a Computer?

Picture of What Is a Computer?
This may seem like a very simplistic question that does not need answering when, in fact, it is a question that many people do not know the true answer to. Computers have existed a lot longer than the transistor in mechanical and theoretical form. The actual definition of a computer was thought up by a very intelligent individual by the name of Alan Turing. He described a machine that was termed the Turing Machine. Every computer that we use today, from the computer or cell phone that you are reading this on to supercomputers all can be classified as a Turing Machine at their most simplistic level.

What is a Turing Machine? A Turing Machine consists of 4 parts: the tape, head, table and state register. To visualize the operation of such a machine you first have to imagine a film strip spanning infinitely in each direction. Now imagine that each cell of this film strip can contain only one of a defined set of symbols (like an alphabet). For this example let us imagine that each cell can only contain either a "0" or a"1". These cells can be rewritten an infinite amount of time but retain their information indefinitely until they are changed again. The part of the Turing Machine known as the head can write symbols to the cells as well as either increment or decrement its position on the film strip by a given integer (whole number) of cells. The next part is the table which holds a given set of instructions for the head to execute such as "move right 4 cells" and "set cell to 1". The fourth and final part of a Turing Machine is its state register whose purpose is to hold the current state of the machine. The state includes the instruction as well as the current data on the tape.

That is how simple the operation of a computer is. When your computer operates, it is actually operating as a turing machine. It processes data held on your computer by a given set of instructions and algorithms. The computer described in this Instructable is a very simplistic model of a computer, but it still operates as one that you can program with a set of instructions that it will follow and execute.

Useful Links:

Wikipedia on Turing Machines: 
http://en.wikipedia.org/wiki/Turing_machine

Step 2: An Introduction to Electronics

Picture of An Introduction to Electronics
M200106P01WL.jpeg
resistor-color-code-all.gif
27_01_Resistors_in_series_and_parallel.jpeg
Transistor.jpg
Before building an 8-bit computer, it is extremely useful to have a grasp on the elemental properties of electricity and analog circuitry. There are parts on the computer you will build will need analog components. There are many electronics self teaching guides available for a minimal cost that provide a crash-course in electrical engineering. I personally found Electronics Self Teaching Guide by Harry Kybet and Earl Boysen to be a wonderful book for tackling the world of analog electronics.

Electronics Self Teaching Guidehttp://www.amazon.com/Electronics-Self-Teaching-Guide-Teaching-Guides/dp/0470289619/

Common Components:

Resistor - Limits current, measured in ohms.

Capacitor - Stores charge, can either be polar or non-polar (polar meaning that it must be placed in the correct direction to work). Measured in farads.

Diode - Only allows current to flow in one direction, breaks down at a certain voltage when placed in the wrong direction.

Transistor - A current gate that is controlled by a third pin that acts as a mediator. There are many types of transistors, but here we will be talking about the BJT (bipolar junction transistor) which comes in two types: NPN and PNP.


Current, voltage and resistance go hand-in-hand in a circuit. The relation between the three can be expressed with Ohm's law: V = IR. In other words, Voltage equals the current in amperes multiplied by the resistance in ohms. Ohm's law is one of the most important formulas in electronics and it is well worth knowing off of the top of your head.

To apply Ohm's law you need to know the resistance of a circuit. To find the value of a resistor you have to use its color code. The resistor color code is based upon the visible spectrum and can be memorized in many different fashions. For those who don't care to memorize it, there is a plethora of tools that exist to help you find the correct value for your resistor. To calculate total resistance in a circuit you need two formulas for two different configurations of resistors: series and parallel. In series one resistor follows the other one, whereas in parallel they work alongside each other. In series the formula is very simple:

Resistors in Series: R(total) = R(1) + R(2) + . . . + R(N)

Meaning that you just have to add up the values of the resistors.

Resistors in Parallel: R(total) = 1/{ 1/R(1) + 1/R(2) + . . . + 1/R(N) }

A good tool to find resistance from color code: http://www.csgnetwork.com/resistcolcalc.html

It is easier to understand the formula for resistors in parallel if you think of the resistors as working together like two people working together on a project. The same formula is used for word problems where you are given the rate at which two person operate and you must find out how fast their project will be completed if the work together.

To find how much current is supplied to a given component with a given resistance value you would simply plug in the resistance and voltage values into Ohm's law and solve for I. For instance:

A light is in a circuit and and two 1K (one thousand ohm) resistors are placed in front of it in parallel. With a power supply of 9 volts, how much current is supplied to the light?
1.) Calculate R(total):
R(total) = 1/( 1/1000 + 1/1000 ) = 1/( 2/1000) = 1000/2 = 500 ohms
2.) Calculate current using Ohm's law:
9 = I * 500
I = 9/500 = .018 A = 18 mA (milliamps)

You can also arrange resistors in a circuit to regulate voltage. This is called a voltage divider and involves two resistors in series. The voltage output of the two resistors is at their junction. For a better idea, look at the picture that I have attached. In this arrangement the formula for voltage output is:

V(out) = V(source) * R(2)/{ R(1) + R(2) }

Capacitors will be useful in your computer with the construction of the clock. The clock is simply a circuit that turns on and off at a constant rate. Just like resistors, capacitors have two formulas for finding the total value for both series and parallel configurations.

Series: C(total) = 1/{ 1/C(1) + 1/C(2) + . . . + 1/C(N) }

Parallel: C(total) = C(1) + C(2) + . . . + C(N)


The rate at which a capacitor charges depends upon the resistance of the circuit before (or after if you are discharging) the capacitor as well as its capacitance. The charging of a capacitor is measured in time constants. It takes 5 time constants to fully charge or discharge a capacitor. The formula for finding the time constant of a capacitor in seconds is:

T(constant) = Resistance * Capacitance

Diodes are simple in operation and come in handy when building a TTL computer. They only allow current to flow in one direction. When they are placed in the correct direction they are what is called forward-biased. When they are reversed they break down at a certain voltage. When a diode is working against the current it is reverse-biased.

A Transistor operates like a valve that is operated by current. A BJT has three pins: the collector, the emitter and the base. For sake of simplicity in this step I will describe a NPN transistor in which current flows from the collector to the emitter. The current applied at the base controls how much of the current flows from the collector to the emitter. Transistors are ideal for many applications due to their ability to amplify a signal. This is because the current applied at the base of the transistor can be considerably less than the current controlled. This gain in current is called the current gain of the transistor, or beta. The formula for beta is:

Beta = Current(Collector)/Current(Base)

When a transistor is completely on it is said to be saturated. A boolean transistor is one that is either in its saturated or off state and never in between. This is the type of transistor that you will be dealing with mostly in digital electronics. Transistors form the logic gates needed for a computer to function. These will be described later.

Useful Links:

http://en.wikipedia.org/wiki/Resistor
http://en.wikipedia.org/wiki/Capacitor
http://en.wikipedia.org/wiki/Diode
http://en.wikipedia.org/wiki/Transistor


Step 3: Binary Numbers

Picture of Binary Numbers
Today we are used to a worldwide numbering system that is based on the number ten. By that I mean that we have no numeral in our number system that is worth the value of ten and thus our number system is base ten.

Think of our number system as an odometer. An odometer counts from the lowest digit to the highest digit and then forces the next rotor in sequence to advance one place. For example:

0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 0 <-- Carry to the next digit

Binary is base two, meaning that it only has two numerals and has no numeral for 2. Binary only has the numerals 0 and 1 or "off" and "on". To count in binary you simply apply the odometer technique:

0001b - 1
0010b - 2
0011b - 3
0100b - 4
0101b - 5
0110b - 6
0111b - 7
1000b - 8
etc . . .

There is another factor of our number system that makes it base ten; as we move higher in digits the weight of numerals increase by a power of ten. For example 1 = 10^0, 10 = 10^1, 100 = 10^2, etc . . . In binary, things of course are base two and as such, each successive numeral is another power of two. 1b = 1 = 2^0, 10b = 2 = 2^1, 100b = 4 = 2^2, etc . . .

To convert a decimal number to binary there is a simple trick known as double-dabble that makes the process a lot more easy:

Say we want to convert 13 to a binary number, we start by dividing 13 by two and writing down the remainder. Then directly above it you write down the resulting number without the remainder (6 in this case) and divide that by two and write down the remainder above the previous one. You continue this process until you reach either a 1 or a 0. At the end you read from the top down to get the result.

1/2   = 0 R1  < Read from top to bottom. The result is 1101 or 2^0 + 0 + 2^2 + 2^3 = 1 + 0 + 4 + 8 = 13. This is called a binary word.
3/2   = 1 R1  <
6/2   = 3 R0  <
13/2 = 6 R1  <

Hexadecimal is used very often with binary. Hexadecimal is base 16 and contains the numerals 0-9 and a-f. One hexadecimal numeral is used to describe one nibble or four bits of data. A bit is a single 1 or 0 of binary. A nibble can count from 0 to 15 (0000 to 1111) before the next bit is in the next nibble. Two nibbles together is a byte or 8 bits. Since the first numeral is 2^0, the last numeral is weighted 2^7. Therefore a byte can be anywhere in the range from 0 to 255. To express the byte 00101110 (46 in decimal) in hexadecimal you would first separate the two nibbles into 0010 and 1110. The first nibble has a value of 2, and the second one has a value of E (or 14 in decimal). Therefore the byte 00101110 in hexadecimal would be 2E.

Useful Links:

http://en.wikipedia.org/wiki/Binary_numeral_system
http://en.wikipedia.org/wiki/Hexadecimal

Step 4: Logic Gates

Picture of Logic Gates
3statbuf.gif
SR-NOR-latch.png
A computer consists of thousands of logic gates arranged to carry out certain functions. A logic gate is a component in digital electronics whose output depends on the state of its inputs. Most logic gates have two inputs and one output. You can think of logic gates as the decision-makers in digital electronics. The six main logic gates used in digital electronics are:

AND Gate: Output is high when all if its inputs are high.

OR Gate: Output is high when any of its inputs are high.

NOT Gate: Only has one input. Output is high when its input is low.

NAND Gate: Output is high unless all of its inputs are high.

NOR Gate: Output is high when none of its inputs are high.

XOR Gate: Output is high when an odd number of inputs are high.


Tri-State Buffer: A buffer that is controlled by a third logic signal.

It is important to mention now the difference between a high "1" signal and a low "0" signal. A high signal can either be a connection to positive voltage or it can be a floating input. A floating input is one that is not connected to any output. An example of a floating input would be one that is not connected at all or one that is connected to the output of a 3-state buffer that is not activated. A low signal is present when an input is at ground.

Logic gates can be fed into each other to produce almost any function imaginable. For instance, two NOR gates can be fed into each other to store one bit of data in a RS_NOR latch while power is supplied to the circuit.

Step 5: Binary Counting (The Program Counter)

Picture of Binary Counting (The Program Counter)
article1.gif
One of the most essential parts to a computer is its program counter. The program counter provides the computer with the current address of the instruction to be executed. In order for the program counter to work, however, it needs to count in binary. To do this JK flip flops are used. A flip-flop is an arrangement of logic gates that stores one bit (like the RS_NOR latch described in the logic gates step). A JK flip-flop changes its state when its clock pulse input goes high and then low again (its J and K inputs also have to be high). In other words, whenever a JK flip flop gets the falling edge of a clock pulse its state changes from either a "0" to a "1" or from a "1" to a "0".

If you connect the output of one JK flip flop to another and cascade them the result is a binary counter that acts like an odometer. This is because as the first JK flip flop in the sequence goes high, and then low, it triggers the next one in the sequence. The clock's frequency (how many times it turns on and off a second) is halved with every successive addition of a JK flip flop. That is why a JK flip-flop is also called a divide-by-two circuit. The resulting pattern for four JK flip flops will be 0000, 0001, 0010, 0011, 0100, etc . . .

For the simple-as-possible computer described in this Instructable, however, there are a few more functions that you need in order to make the computer operational. In order for the computer to be able to restart its program it needs the ability to clear or set all of its outputs to zero. The program counter also needs the ability to load a binary word for the JMP op code which allows the computer to jump to a certain instruction. Logic gates are used to achieve this goal. Fortunately for us binary counters come in convenient chips with all of the functions that you need.

Step 6: Registers

Picture of Registers

Registers:

Registers could potentially be the most important part of a computer. A register temporarily stores a value during the operation of a computer. The 8-bit computer described in this Instructable has two registers attached to its ALU, a register to store the current instruction and a register for the output of the computer.

Depending on the chip, a register will have 2 or 3 control pins. The registers that we will be using have two control pins: output enable and input enable (both active when low). When the output enable pin is connected to ground the currently stored binary word is sent out across the output pins. When the input pin is connected to ground the binary word present on the input pins is loaded into the register.

An example of the use of a register on a computer is the accumulator on the ALU (arithmetic logic unit that performs mathematical operations). The accumulator is like the scratchpad for the computer that stores the output of the ALU. The accumulator is also the first input for the ALU. The B register is the second input. For an addition operation, the first value is loaded into the accumulator. After that the second value to be added to the first value is loaded into the B register. The outputs of the accumulator and B register are fused open and are constantly feeding into the ALU. The final step for addition is to transfer the output of the operation into the Accumulator.

Registers all operate on a shared data line called the bus. The bus is a group of wires equal in number to the architecture of any CPU. This is really putting the horse before the cart considering bus width is the defining measurement for CPU architecture. Since a digital 1 means positive voltage, and a 0 means grounding, it would be impossible to have all registers share the same bus without giving them the ability to selectively connect and disconnect from the bus. Luckily for us, there is a third state between 1 and 0 that is ambivalent to current imput that works great for this. Enter the tri-state buffer: a chip that allows you to selectively connect groups of wires to a bus. Using some of these tri-state-buffers, you can have every register and chip on the entire computer needing of communication share the same wires as a bus. In the case of my computer, it was an 8-wire wide band of breadboard slots that spanned the bottom pins of the breadboard. Experiment around with busses, since they carry all of the information from piece to piece in the computer a faulty buss could mean erroneous data that ripples down the line.

Step 7: The ALU

Picture of The ALU
adder-subtractor-circuit.gif
Image1.gif
DSC01798.JPG
Scan 2 copy.jpg
The ALU (arithmetic logic unit) of a computer is the part that executes mathematical operations. For the SAP computer it will only need to have two functions: addition and subtraction. Adding and subtracting in binary works very similarly to addition and subtraction in decimal terms, for example:
  1<-- Carry           1  1 <-- Carry Bits
  05                         0101
+05                      +0101
  10                         1010

To add binary we need what is called a full-adder. A full-adder effectively adds one bit of binary to another with a carry in and carry out. The carry in of a full adder is like a third input for the addition process. They are used to chain multiple full-adders together. The carry out of a full-adder occurs when there is a pair of ones in the addition process. The carry out of a full adder is fed into the carry in to add multiple bits of binary. To construct a full adder you need two XOR gates, two AND gates and an OR gate.

To subtract binary we need to convert a number to its negative counterpart and add it to the number we are subtracting from. To do this we use what is called 2's compliment. To take the 2's compliment of a binary word you invert each bit (change every 0 to a 1 and every 1 to a 0) and add one.

5 = 0101, -5 = 1010+1 = 1011

         Not used-->1    1   
   10                           1010
+(-5)                        +1011
  5                               0101

To control the inversion of bits we use XOR gates with one normally low input. With one normally low input, the output is equivalent to the other input. When you set the control input high you invert the other input. If we couple this inversion with a bit sent to the carry in of the full adders a subtraction operation is the result.

Step 8: Program Memory and RAM

Picture of Program Memory and RAM
The program memory of your computer will store the instructions to be executed. It will also act as RAM that can store values during the operation of the computer. The program memory consists of three main parts: the memory, the memory address register (MAR) and the multiplexer. The memory is a chip that has 16 bytes of storage. There is a four bit address that is fed into the memory that tells it what byte it should read or write. The MAR stores the current address for the byte to be read or written from the memory. It is constantly feeding into the memory chip unless the computer is in its programming state. A multiplexer allows you to choose between two inputs and output the given input. The multiplexer used in my computer allows you to select from two four bit inputs (the MAR and a manual input). When the computer is in its programming state the manual address is fed into the memory and allows you to program bytes into the computers memory at the address that you define.

Step 9: Instruction Register

Picture of Instruction Register
The instruction register of a computer stores the current instruction as well as an address that the instruction will operate on. It is a very simple component with a very important purpose. During the operation of the computer, the content of a given address in memory is transfered into the instruction register. In my computer the leftmost fout bits are the OP code or current instruction to be carried out. The right four bits, or lowest four bits, tell the computer what address to use for the operation. The first four bits constantly feed the OP code into the control matrix which tells the computer what to do for a given instruction. The rightmost four bits feed back into the computer so that the address can be transferred into the MAR or program counter.

Step 10: Output Register

Picture of Output Register
DSC01809.JPG
If a computer were to just feed the output of the bus to the operator, the readout would make little to no sense. This is why there is an output register whose purpose is to store values meant for output. The output for your computer can either be simple LED's that display raw binary, or you could have a display that reads out actual numbers on seven-segment displays. It all depends how much work you want to put into your computer. For my computer I am using some IV-9 Russian Numitron tubes for the output of my computer coupled with an Arduino to do the conversion from binary to decimal.

Step 11: Clock

Picture of Clock
Every part in the computer has to be completely synchronized in order to function correctly. In order to do this your computer needs a clock or a circuit that has an output that turns on and off at a constant rate. The easiest way to do this is to use a 555 timer. The 555 timer is an extremely popular timer that was invented in the era of the emergence of the computer that is stille extremely popular with hobbyists today. To build the 555 circuit you need to know how one operates.

The clock for your computer should be relatively slow at first. 1Hz, or one cycle per second, is a good starting value. This allows you to view the operation of your computer and check for any errors. The 555 chip needs two resistors and a capacitor for operation. The two resistors determine how long the high and low pulses are as well as the overall frequency. The capacitor changes the pulse length for both. If you do not have any experience with 555 timers I recommend experimenting with them.

Useful Links:

http://en.wikipedia.org/wiki/555_timer_IC

Step 12: Architecture

Picture of Architecture
DSC01850.JPG
SAP1Architecture.jpeg
This is the step where everything comes together. It is time to design the architecture of your computer. The architecture is how the registers and different components of your computer are organized. The design aspect is completely up to you, although it helps to keep a goal in mind (what you want your computer to do) and a model to go off of. If you want to design your computer after mine it is completely fine. I modified the architecture of the SAP-1 found in Digital Computer Electronics for my 8-bit computer.

One design aspect to always keep in mind is how data is transferred between the various components of your computer. The most common method is to have a common "bus" for all of the data on the computer. The inputs and outputs of the registers, ALU, program counter and RAM all are connected to the computer's bus. The wires are arranged in order from least significant bit (1) to highest significant bit (128).

Any and all outputs that are connected to the bus have to be completely disconnected while inactive or else they would merge with each other and result in erroneous output. To do this we use Tri-state buffers to control the output of certain elements that output by default like the accumulator, ALU and actual input for the programming of the computer.

Step 13: Control Matrix

Picture of Control Matrix
The control matrix of a computer tells each individual part when to take input and output its value. There are multiple states of each operation in a computer. These states are triggered by a type of counter called a ring counter. A ring counter only has one bit high at a time and cycles through its outputs consecutively. For instance, if a ring counter has 4 outputs it will first have its first output active. At the next clock pulse it will set its second output high (and the first low). The next clock pulse will advance the bit one output higher and so on. These stages are called T states. The computer in this Instructable uses 6 T states for the operation of one command. The first three T states are what is called the fetch cycle in which the current instruction is fetched and placed into the instruction register. The program counter is also incremented by one. The second set of three T states depends on what OP code is fed into the control matrix from the instruction register. The T states are as follows:

T1: The contents of the program counter are transferred into the memory address register. (Address State)
T
2: The program counter is incremented by one. (Increment State)
T3: The addressed byte in the program memory is transfered into the instruction register. (Memory State)
T4: Dependent on what command is being executed.
T5: Dependent on what command is being executed.
T6: Dependent on what command is being executed.

There are two primary ways to create a control matrix: using discrete logic and using ROM's. The ROM method is the easiest and most efficient. Using discrete logic involves designing a massive logic schematic that will output the correct control words for your computer based on an OP code input. ROM stands for read-only-memory. There are several types of ROM's that you can consider for use in your build. For my computer I originally used EEPROM (electronically erasable programmable ROM) but then shifted to NVRAM (non-volatile random access memory) after the EEPROM chips failed to write. I do not recommend NVRAM as it is meant for random access memory and not permanent storage. EEPROM is the most efficient solution in my opinion.

The control matrix will have three ROM chips each having at least 32 addresses of 8 bit storage (as well as the timing and counting elements). The binary word that is sent out from the control matrix is called the control ROM and contains all of the control bits for every component of your computer. You want to be sure to organize the control bits and know their order. For no operation you want a control word that renders every part of the computer inactive (except the clock of course). The control word for the computer described in this Instructable is 16 bits in length and is stored in two of the control ROM chips. The first three addresses of the control ROM chips hold the control words for the fetch cycle. The rest of the addresses on the chip hold the control words in pairs of three for each OP code. The third ROM chip holds the memory location for the start of the control word sequence for each OP code and is addressed by the OP code itself. For instance, in my computer if you give the control the OP code 0110 it will output binary 21, which is the address of the start of the JMP command. There is an 8-bit counter in between the OP ROM and the control ROM's that counts from 0-2 (first three T states) then on the third T state loads the address outputted by the OP ROM and counts from that position until the T1 state clears the counter again. The ring and binary counter for the control matrix are controlled by an inversion of the clock pulse so that control words are present when the rising clock pulse goes to the elements of the computer. The entire process in order is as follows:

1.) T1 state clears the counter to 0, the control word stored at 0 is sent out
2.) The clock goes high and the address state takes place
3.) The clock goes low and in turn the control counter increments and control word 1 is sent out
4.) The clock goes high and the increment cycle takes place
5.) The clock goes low and the control counter increments to 2, control word 2 is sent out
6.) The clock goes high and the memory state takes place and the OP code arrives at the instruction register, T3 is also active which means on the next low clock pulse the OP control address will be loaded
7.) The clock goes low and loads the counter with the address for the first of the three control words for the given OP code
8.) T4, T5 and T6 execute the OP code
9.) T1 resets the counter, the process continues until a HLT OP is received. The HLT command stops the clock.

Step 14: Microprogramming

Picture of Microprogramming
DSC01805.JPG
DSC01824.JPG
Now is the part where you decide what commands you want your computer to be capable of. I gave my computer 6 unique operations that would give it the basic programming functions that I would need. The commands that you will program into your computer are what is called Assembly language. Assembly is one of the earliest programming languages and can still be used on computers today. Commands in the language include loading the accumulator, adding, moving, outputting and storing variables. Each command has its own 4-bit OP code in this 8-bit computer. The commands that I chose for my computer are:

NOP: No operation. (0000)
LDA: Load the accumulator with the value at this address. (0001)
ADD: Add the value at the specified address to the value in the accumulator. (0010)
SUB: Subtract the value at the specified address from the value in the accumulator. (0011)
STO: Store the accumulator's contents at the specified address. (0100)
OUT: Store the accumulator's contents in the output register so that the operator can see it. (0101)
JMP: Jump to a certain instruction in memory at the specified address. (0110)
HLT: Stop the operation of the computer. (0111)

To determine what control words need to be sent out for each OP you need to know what bits have to be active during each T state. For my computer I organized the bits as follows (an underline denotes an active-low bit):

CE CO J MI RO II IO OI BI EO SU AI AO RI HLT X

CE - Count Enable (enables the program counter's clock input)
CO - Clock out enable
J - Jump enable
MI - MAR Input
RO - Program memory out
II - Instruction register in
IO - Instruction register out
OI - Output register in
BI - B register in
EO - ALU output enable
SU - Subtract
AI - Accumulator in
AO - Accumulator output enable
RI - Program memory in
HLT - Halt
X - Not used

Here are what bits should be active for each T state for a given instruction as well as the address that they should be in the control ROM:

Fetch:
0: CO, MI - The program counter outputs into the MAR
1: CE - The counter is enabled for the next clock pulse
2: RO, II - The addressed byte is outputted from RAM into the instruction register

NOP:
3: X
4: X
5: X

LDA:
6: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
7: RO, AI - The addressed byte is outputted from memory into the accumulator
8: X

ADD:
9: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
10: RO, BI - The addressed byte is outputted from memory into the accumulator
11: EO, AI - The sum of the accumulator and the B register is loaded into the accumulator

SUB:
12: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
13: RO, BI - The addressed byte is outputted from memory into the accumulator
14: AI, SU, EO - The difference of the accumulator and the B register is loaded into the accumulator

STO:
15: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
16: AO, RO, RI - The accumulator outputs into the program memory at the addressed location (RO and RI have to be active for a write on the chip that I used)
17: X

OUT:
18: OI, AO - The accumulator outputs into the output register
19: X
20: X

JMP:
21: J, IO - The instruction register loads the program counter with its lowest four bits
22: X
23: X

HLT:
24: HLT - A halt signal is sent to the clock
25: X
26: X

Your OP ROM contains multiples of three at each memory location. This is of course because each cycle takes three execution states. Therefore the addressed data for your OP ROM will be:
0 - 3
1 - 6
2 - 9
3 - 12
4 - 15
5 - 18
6 - 21
7 - 24

To program your choice of chip you have many different options. You could buy an EEPROM and EPROM programmer, but they usually cost a considerable amount of money. I built a breadboard programmer for my ROM that is operated by moving wires around and controlling the write and read enable pins by push buttons. Later I simplified the process and designed an Arduino programmer for my NVRAM specifically. I'll attach the code as it can be easily modified to program almost any parallel memory chip that you would use for this project.

Step 15: Buying Parts

Picture of Buying Parts

The great thing about building an 8-bit computer is that most parts will cost you less than a dollar a piece if you buy them from the correct place. I purchased 90% of my parts from Jameco Electronics and I have been completely satisfied with their services. The only parts I have really bought from anywhere else are the breadboards and breadboard wires (and the Numitron tubes). These can be found considerably cheaper on sites like Amazon. Always be sure to make sure the parts that you are ordering are the correct ones. Every part that you buy should have a datasheet available online that explains all of the functions and limitations of the item that you are buying. Make sure to keep these organized as you will be using many datasheets in the construction of your computer. To help you with your computer I will list the parts that I used for mine:

4-Bit Counter:
74161 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74161&langId=-1&storeId=10001&productId=49664&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView

4-Bit Register (I use two for each 8-bit register):
74LS173 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74LS173&langId=-1&storeId=10001&productId=46922&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView

2-1 Multiplexer:
74LS157 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_46771_-1

16x8 RAM (output needs to be inverted):
74189 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74189&langId=-1&storeId=10001&productId=49883&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView

Full Adders:
74LS283 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74LS283&langId=-1&storeId=10001&productId=47423&search_type=all&catalogId=10001&ddkey=http:StoreCatalogDrillDownView

Tri-State Buffers:
74S244 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_910750_-1


XOR Gates:
74LS86 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_295751_-1

AND Gates:
74LS08 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_295401_-1

NOR Gates:
74LS02 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_283741_-1

Inverters:
74LS04 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_283792_-1

Ring Counter:
CD4029 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=4029&langId=-1&storeId=10001&productId=12925&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView

JK Flip-Flops:
74LS10 -http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_295427_-1

Step 16: Construction

Picture of Construction
control logic.jpg
Here is where the patience really comes in. I chose using a breadboard for the actual computer, but there are many other methods out there (such as wire-wrapping) that will work just as well. To make things a lot more simple I included a block diagram for the actual schematic of my computer. I did not however include part numbers or pin numbers. I believe that this will make things more simple and open for creativity. The 4-bit program counter output, MAR input and instruction register output are all connected to the four least significant bits of the computer's bus.

The second diagram shown is the control logic for the operation end of the computer. The controls are designed so that toggles can be an input for the computer. RS_NOR latches are placed in front of the toggle switches to debounce them. Toggle switches often have dirty connections that may bounce from an on to an off state and provide more pulses than you want. Adding a flip-flop to the output of a toggle eliminates the extra pulses. This would be extremely useful when using the manual clock option. You would not want to flip the switch and initiate 8 clock pulses. The read/write button writes the active input byte to the addressed memory. By changing the default control word input to RAM to two low RO and RI bits initiating a write cycle. The run/program switch changes which input is active on the memory address multiplexer. The JK flip flop after the 555 means that when the computer is run, it will not start on the middle of a clock pulse. A low HLT signal will stop the clock from passing on either the manual clock or 555. And finally, the run/clear switch is connected to all of the clear pins on the computer such as those on the registers and counters.

Step 17: Programming

Picture of Programming
Now that the computer is done, it can be programmed to carry out instructions. To do this you first have to put the computer into its program setting by flipping the run/program toggle switch into the program position. After that you select addresses starting at 0 and going to 15 and insert the needed data for your program. For instance, to start with 5 and add 4 with every output the program would be as follows:

Address - Data:
0000 - 00010111   LDA 7: Load the accumulator with the value stored at memory address 7 (5)
0001 - 00101000   ADD 8: Add value stored at memory address 8 (4)
0010 - 01010000   OUT: Output the accumulator
0011 - 01100001   JMP 1: Jump to instruction 1
0100 - X
0101 - X
0110 - X
0111 - 00000101   5
1000 - 00000100   4
1001 - X
1010 - X
1011 - X
1100 - X
1101 - X
1110 - X
1111 - X

Step 18: Going Further

Picture of Going Further
I hope you enjoyed this Instructable and, most of all, I hope that you got something out of it. You can consider all of this hard work an incredibly valuable learning experience that will give you a better understanding of electronics, computers and programming. In the end you will also have something very cool to show for all of your hard work as well.

After constructing your first 8-bit computer you can go further and add more functionality. The ALU used in this computer is very simplistic in operation and true ALU's today have a myriad of functions such as bit-shifting and logical comparisons. Another important aspect to move onto is conditional branching. Conditional branching means that an instruction depends on the current state of flags set by the ALU. These flags change as the accumulator's contents become negative or are equal to zero. This allows for a much more expansive possibility for application of your computer.

If you have any questions about this project feel free to comment on this Instructable, comment on my website at http://8bitspaghetti.com or shoot me an email at sudokyle@gmail.com. I wish you the best of luck with this project.


'Hardware' 카테고리의 다른 글

SPI(Serial Peripheral Interface Bus)  (0) 2015.08.04
I2C(Inter Integrated Circuit)  (0) 2015.08.04
UART란?  (0) 2015.08.04
led는 안다리가 짧은게 vcc  (0) 2015.01.03
간단한 레귤레이터 만들기 11V->5V  (0) 2014.12.30




포인터를 호출할땐 저렇게포인터 자체를 넣어주면 된다.

하지만 또 그냥 함수안에서 포인터의 주소를 쓰자면 p라고 써주면된다.

Auto running applications in the GUI

See here 

Auto running terminal applications (non GUI)

First ensure your program is executable by finding it in the file manager.  Right click on the file and select properties.  Select the permissions tab, check the ‘Make the file executable’ box and press OK.  Or from the command line use:


sudo chmod +x /home/pi/projects/my_project.a

Or using a different tool set its chmod to 755 (rwxr-xr-x).  It doesn't matter if the user is root.

Doesn't work?

We've found that when copying a new file to the rpi using WinSCP, changing its properties to 755 and verifying all is OK that if we kill the power and power up again the executable doesn't run.  However if we use sudo reboot at the command line it works as it should.  It seems there is some sort of caching action going on so after doing this use sudo reboot the first time rather than cycling the power!

You can setup the auto run using a script (see here), or you can do it directly by editing the rc.local file:


sudo nano /etc/rc.local

 

After the initial comments (lines beginning with '#') add the following lines:


# Auto run our application
sudo /home/pi/projects/my_project.a &

"sudo" assumes you want your application run with root user privileges (remove if not) and the "&" says do it in the background.

Save it by pressing Ctrl+X, " Y", ENTER

Re-boot your RPi and it will run.

To kill the program

If you need to kill your program running in the background you can use this


sudo killall my_project.a

 

Running multiple things and also programs as a non root user

You can use brackets around multiple commands each separated by a ';' followed by the '&' to run the set of commands all in the background.

If you use the '&' you can also run multiple lines as each is run in the background.

Finally, by default rc.local runs as the root user.  You can change to a different user using su – USERNAME -c before the command and surrounding it with quotes.

In the example below the following occurs:

After a 2 second pause my_project.a us run in the background.

After a 5 second delay VLC is started to stream the raspberry pi video camera.  VLC won't run as the root user so su -c is used to make it run as the user "pi"


#Auto run our application
(sleep 2;sudo /home/pi/projects/my_project/my_project.a)&
#Auto run VLC video streaming
(sleep 5;su - pi -c "raspivid -o - -t 0 -n -w 640 -h 480 -fps 15 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264")&

 


'Linux > RaspberryPi' 카테고리의 다른 글

Raspberry Pi에서 Java 설치하기!  (0) 2015.06.25
Setting Up VNC  (0) 2015.06.24
(cpp)wiringpi활용  (0) 2015.01.03
(python)GPIO 끄기: GPIO cleanup()  (0) 2015.01.03
RaspberryPi GPIO+WiringPi  (0) 2014.12.30

+ Recent posts