As others are pointing to you, you're confusing relative paths vs. absolute paths. Put in mind the following considerations:
- A lone slash
/
is the root directory. Think of it as the folder that is on top of all other folders, that is, every folder and file in your system is somewhere inside the /
directory.
- An absolute path is a path from the root directory to a file or folder. Thus, it always begins with
/
, which is the root directory, and ends with the file or folder you want to reach. An example of an absolute path for a file would be:
/home/username/Desktop/myFile.txt
- The tilde
~
is a shortcut that represents your home directory. Thus, a file somewhere inside your home folder can be accessed by using this shortcut, and the above example could be:
~/Desktop/myFile.txt
- The current directory or working directory is the one you're currently working on. It is normally displayed on the Bash prompt in blue, between the semicolon
:
and the dollar sign $
. For example, if you're currently working on your Desktop
folder, the Bash prompt on the Terminal would be like this:
username@hostname:~/Desktop$
- A relative path can be used when the file or folder you want to access is inside your current working directory. In that case, you must not begin the path with
/
, because that would represent that the path is an absolute path starting in the root directory. As an example, if you're already working on your Desktop
folder, you could read the contents of the myFile.txt
file by just typing its name.
username@hostname:~/Desktop$ cat myFile.txt
- The current directory can be represented by a single dot
.
. Thus, to prevent mistakes and make sure you're referencing a relative path, you may begin relative paths with ./
to represent something inside the current directory, e.g.:
username@hostname:~/Desktop$ cat ./myFile.txt
- The directory above your working directory is represented by two dots
..
. Thus, if you're in your Downloads folder but want to access your file on the Desktop, you could use the following relative path:
username@hostname:~/Downloads$ cat ../Desktop/myFile.txt
As a further example, if the myFile.txt
is inside the someFolder
directory on your Desktop, then you could read its contents using either:
- A relative path (no slash at the beginning):
username@hostname:~/Desktop$ cat someFolder/myFile.txt
- A relative path with the dot, to avoid confusion:
username@hostname:~/Desktop$ cat ./someFolder/myFile.txt
- The absolute path (with a slash at the beginning):
username@hostname:~/Desktop$ cat /home/username/Desktop/someFolder/myFile.txt
- The absolute path with the home directory shortcut:
username@hostname:~/Desktop$ cat ~/Desktop/someFolder/myFile.txt
Please, make some practice with this, then come back and you will understand the other answers.
In short, your file is now inside your root directory and its name is the same as the name of the folder you were trying to put it into. Thus the absolute path to the file is now /Modules_and_packages_Game
(it is still a python file, it's just missing the .py
extension because you inadvertently changed its name). This is different from the folder you have in ~/Desktop/1 linux and python steps/Modules_and_packages_Game
. To put the python file into that folder and change its name back, use:
mv /Modules_and_packages_Game "~/Desktop/1 linux and python steps/Modules_and_packages_Game/Modules_and_packages.py"
(Note the double quotes "
are needed because you have whitespaces in the path.)